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)
5K/s
Array.apply(null, { length: 4 })
655/s
[...Array(n).keys()].map(k => undefined)
133/s
Array.from
130/s
for loop push
115/s
View exact numbers
Test name Executions per second
Array(n).fill(undefined) 5,154 Ops/sec
Array.apply(null, { length: 4 }) 655 Ops/sec
[...Array(n).keys()].map(k => undefined) 133 Ops/sec
Array.from 130 Ops/sec
for loop push 115 Ops/sec
Script Preparation code:
Tests: