Run details:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36
Chrome 123
Linux
Desktop
2 years ago
Array(n).fill(undefined)
2K/s
Array.apply(null, { length: 4 })
294/s
Array.from
67/s
[...Array(n).keys()].map(k => undefined)
66/s
for loop push
61/s
View exact numbers
Test name Executions per second
Array(n).fill(undefined) 1,796 Ops/sec
Array.apply(null, { length: 4 }) 294 Ops/sec
Array.from 67 Ops/sec
[...Array(n).keys()].map(k => undefined) 66 Ops/sec
for loop push 61 Ops/sec
Script Preparation code:
Tests: