Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36
Chrome 129
Windows
Desktop
one year ago
Array(n).fill(undefined)
3K/s
Array.apply(null, { length: 4 })
368/s
Array.from
82/s
[...Array(n).keys()].map(k => undefined)
82/s
for loop push
70/s
View exact numbers
Test name Executions per second
Array(n).fill(undefined) 3,279 Ops/sec
Array.apply(null, { length: 4 }) 368 Ops/sec
Array.from 82 Ops/sec
[...Array(n).keys()].map(k => undefined) 82 Ops/sec
for loop push 70 Ops/sec
Script Preparation code:
Tests: