Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36
Chrome 128
Windows
Desktop
3 months ago
Test name Executions per second
Array.apply(null, Array(n)) 59594.6 Ops/sec
[...Array(n)] 97268.6 Ops/sec
Array(n).fill(null) 94976.0 Ops/sec
Array.from({ length: n }) 9479.9 Ops/sec
Array.from({ length:n }, (item, i) => i) 9309.7 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)