Run details:
Mozilla/5.0 (X11; Linux x86_64; rv:128.0) Gecko/20100101 Firefox/128.0
Firefox 128
Linux
Desktop
2 years ago
Array(n).fill(undefined)
2K/s
for loop push
1K/s
Array.from
787/s
[...Array(n).keys()].map(k => undefined)
427/s
Array.apply(null, { length: 4 })
427/s
View exact numbers
Test name Executions per second
Array(n).fill(undefined) 1,754 Ops/sec
for loop push 1,498 Ops/sec
Array.from 787 Ops/sec
[...Array(n).keys()].map(k => undefined) 427 Ops/sec
Array.apply(null, { length: 4 }) 427 Ops/sec
Script Preparation code:
Tests: