Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36 Edg/115.0.1901.203
Chrome 115
Windows
Desktop
one year ago
Test name Executions per second
Array.apply(null, Array(n)) 269137.1 Ops/sec
[...Array(n)] 518485.0 Ops/sec
Array(n).fill(null) 428731.8 Ops/sec
Array.from({ length: n }) 25783.4 Ops/sec
Array.from({ length:n }, (item, i) => i) 24297.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)


;