Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36
Chrome 139
Mac OS X 10.15.7
Desktop
11 months ago
Array(n).fill(undefined)
11K/s
for loop push
2K/s
Array.apply(null, { length: 4 })
890/s
[...Array(n).keys()].map(k => undefined)
544/s
Array.from
469/s
View exact numbers
Test name Executions per second
Array(n).fill(undefined) 11,440 Ops/sec
for loop push 1,637 Ops/sec
Array.apply(null, { length: 4 }) 890 Ops/sec
[...Array(n).keys()].map(k => undefined) 544 Ops/sec
Array.from 469 Ops/sec
Script Preparation code:
Tests: