Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:135.0) Gecko/20100101 Firefox/135.0
Firefox 135
Windows
Desktop
11 months ago
for loop push
3K/s
Array(n).fill(undefined)
3K/s
Array.from
1K/s
[...Array(n).keys()].map(k => undefined)
660/s
Array.apply(null, { length: 4 })
604/s
View exact numbers
Test name Executions per second
for loop push 2,760 Ops/sec
Array(n).fill(undefined) 2,501 Ops/sec
Array.from 1,137 Ops/sec
[...Array(n).keys()].map(k => undefined) 660 Ops/sec
Array.apply(null, { length: 4 }) 604 Ops/sec
Script Preparation code:
Tests: