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
2K/s
Array(n).fill(undefined)
1K/s
Array.from
739/s
[...Array(n).keys()].map(k => undefined)
431/s
Array.apply(null, { length: 4 })
343/s
View exact numbers
Test name Executions per second
for loop push 1,978 Ops/sec
Array(n).fill(undefined) 1,294 Ops/sec
Array.from 739 Ops/sec
[...Array(n).keys()].map(k => undefined) 431 Ops/sec
Array.apply(null, { length: 4 }) 343 Ops/sec
Script Preparation code:
Tests: