Tests:
  • Array From

    x
     
    function createDateArrayInAMonth(year, month) {
        return Array.from(
            { length: new Date(year, month, 0).getDate() },
            (_, i) => new Date(year, month - 1, i + 1).toLocaleString()
        )
    }
    createDateArrayInAMonth(2023, 10)
  • new Array

     
    function createDateArrayInAMonth(year, month) {
        return new Array(new Date(year, month, 0).getDate()).fill().map((_, i) => new Date(year, month - 1, i + 1).toLocaleString())
    }
    createDateArrayInAMonth(2023, 10)
  • Array

     
    function createDateArrayInAMonth(year, month) {
        return Array(new Date(year, month, 0).getDate()).fill().map((_, i) => new Date(year, month - 1, i + 1).toLocaleString())
    }
    createDateArrayInAMonth(2023, 10)
  • for push

     
    function createDateArrayInAMonth(year, month) {
        const arr = []
        
        for (let i = 0; i < new Date(year, month, 0).getDate(); i++) {
          arr.push(new Date(year, month - 1, i + 1).toLocaleString())
        }
        
      return arr
    }
    createDateArrayInAMonth(2023, 10)
  • for index

     
    function createDateArrayInAMonth(year, month) {
        const arr = []
        
        for (let i = 0; i < new Date(year, month, 0).getDate(); i++) {
          arr[i] = new Date(year, month - 1, i + 1).toLocaleString()
        }
        
      return arr
    }
    createDateArrayInAMonth(2023, 10)
  • While

     
    function createDateArrayInAMonth(year, month) {
        const date = new Date(year, month - 1, 1)
        const arr = []
        
        while (date.getMonth() === month - 1) {
          arr.push(new Date(date).toLocaleString())
          
          date.setDate(date.getDate() + 1)
        }
      
      return arr
    }
    createDateArrayInAMonth(2023, 10)
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    Array From
    new Array
    Array
    for push
    for index
    While

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: one year ago)
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36
Chrome 119 on Windows
View result in a separate tab
Test name Executions per second
Array From 14252.9 Ops/sec
new Array 15203.5 Ops/sec
Array 14870.6 Ops/sec
for push 12916.7 Ops/sec
for index 12758.7 Ops/sec
While 14120.9 Ops/sec