Tests:
  • Array.apply(null, Array(n))

  • [...Array(n)]

  • Array(n).fill(null)

  • Array.from({ length: n })

  • Array.from({ length:n }, (item, i) => i)

Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results
  • Test case name Result
    Array.apply(null, Array(n))
    [...Array(n)]
    Array(n).fill(null)
    Array.from({ length: n })
    Array.from({ length:n }, (item, i) => i)

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 15 days ago)
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.0 Safari/605.1.15
Safari 18 on Mac OS X 10.15.7
View result in a separate tab
Test name Executions per second
Array.apply(null, Array(n)) 85400.5 Ops/sec
[...Array(n)] 166490.1 Ops/sec
Array(n).fill(null) 439787.9 Ops/sec
Array.from({ length: n }) 293047.4 Ops/sec
Array.from({ length:n }, (item, i) => i) 534151.1 Ops/sec


;