Run details:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36
Chrome 145
Linux
Desktop
one month ago
Test name Executions per second
[...Array(n)] 107696.2 Ops/sec
Array(n).fill(null) 108739.3 Ops/sec
Array.from({ length: n }) 20517.1 Ops/sec
Array.from({ length:n }, (item, i) => i) 20047.6 Ops/sec
while(up--) myArray.push(Math.random()); 60162.4 Ops/sec
Tests:
  • [...Array(n)]

  • Array(n).fill(null)

  • Array.from({ length: n })

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

  • while(up--) myArray.push(Math.random());