Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:127.0) Gecko/20100101 Firefox/127.0
Firefox 127
Windows
Desktop
2 months ago
Test name Executions per second
Array.apply(null, Array(n)) 16247.0 Ops/sec
[...Array(n)] 46215.0 Ops/sec
Array(n).fill(null) 76429.9 Ops/sec
Array.from({ length: n }) 71195.5 Ops/sec
Array.from({ length:n }, (item, i) => i) 98242.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)