Run details:
Mozilla/5.0 (Android 11; Mobile; rv:105.0) Gecko/105.0 Firefox/105.0
Firefox Mobile 105
Android
Mobile
2 years ago
Test name Executions per second
[...Array(n).keys()].map(k => undefined) 188.8 Ops/sec
Array.apply(null, { length: 4 }) 236.5 Ops/sec
Array.from 291.1 Ops/sec
Array(n).fill(undefined) 329.2 Ops/sec
for loop push 306.0 Ops/sec
Script Preparation code:
Tests:
  • [...Array(n).keys()].map(k => undefined)

  • Array.apply(null, { length: 4 })

  • Array.from

  • Array(n).fill(undefined)

  • for loop push