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