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
4 months ago
Array(n).fill(null)
109K/s
[...Array(n)]
108K/s
while(up--) myArray.push(Math.random());
60K/s
Array.from({ length: n })
21K/s
Array.from({ length:n }, (item, i) => i)
20K/s
View exact numbers
Test name Executions per second
Array(n).fill(null) 108,739 Ops/sec
[...Array(n)] 107,696 Ops/sec
while(up--) myArray.push(Math.random()); 60,162 Ops/sec
Array.from({ length: n }) 20,517 Ops/sec
Array.from({ length:n }, (item, i) => i) 20,048 Ops/sec
Tests: