Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:122.0) Gecko/20100101 Firefox/122.0
Firefox 122
Windows
Desktop
2 years ago
for loop push
3K/s
Array(n).fill(undefined)
2K/s
Array.from
1K/s
[...Array(n).keys()].map(k => undefined)
595/s
Array.apply(null, { length: 4 })
420/s
View exact numbers
Test name Executions per second
for loop push 2,758 Ops/sec
Array(n).fill(undefined) 2,210 Ops/sec
Array.from 1,037 Ops/sec
[...Array(n).keys()].map(k => undefined) 595 Ops/sec
Array.apply(null, { length: 4 }) 420 Ops/sec
Script Preparation code:
Tests: