Run details:
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
Mac OS X 10.15.7
Desktop
15 days ago
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
Tests:
  • Array.apply(null, Array(n))

  • [...Array(n)]

  • Array(n).fill(null)

  • Array.from({ length: n })

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


;