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