Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:121.0) Gecko/20100101 Firefox/121.0
Firefox 121
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)
621/s
Array.apply(null, { length: 4 })
395/s
View exact numbers
Test name Executions per second
for loop push 2,704 Ops/sec
Array(n).fill(undefined) 1,968 Ops/sec
Array.from 1,068 Ops/sec
[...Array(n).keys()].map(k => undefined) 621 Ops/sec
Array.apply(null, { length: 4 }) 395 Ops/sec
Script Preparation code:
Tests: