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