Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36
Chrome 127
Windows
Desktop
one year ago
Array(n).fill(undefined)
4K/s
Array.apply(null, { length: 4 })
511/s
[...Array(n).keys()].map(k => undefined)
104/s
Array.from
97/s
for loop push
88/s
View exact numbers
Test name Executions per second
Array(n).fill(undefined) 3,915 Ops/sec
Array.apply(null, { length: 4 }) 511 Ops/sec
[...Array(n).keys()].map(k => undefined) 104 Ops/sec
Array.from 97 Ops/sec
for loop push 88 Ops/sec
Script Preparation code:
Tests: