Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:132.0) Gecko/20100101 Firefox/132.0
Firefox 132
Windows
Desktop
one year ago
for loop push
4K/s
Array(n).fill(undefined)
4K/s
Array.from
2K/s
[...Array(n).keys()].map(k => undefined)
948/s
Array.apply(null, { length: 4 })
704/s
View exact numbers
Test name Executions per second
for loop push 4,297 Ops/sec
Array(n).fill(undefined) 3,918 Ops/sec
Array.from 1,944 Ops/sec
[...Array(n).keys()].map(k => undefined) 948 Ops/sec
Array.apply(null, { length: 4 }) 704 Ops/sec
Script Preparation code:
Tests: