Run details:
Mozilla/5.0 (iPhone; CPU iPhone OS 18_0_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.0.1 Mobile/15E148 Safari/604.1
Mobile Safari 18
iOS 18.0.1
Mobile
29 days ago
Test name Executions per second
[...Array(n).keys()].map(k => undefined) 210.9 Ops/sec
Array.apply(null, { length: 4 }) 0.0 Ops/sec
Array.from 220.6 Ops/sec
Array(n).fill(undefined) 18228.0 Ops/sec
for loop push 151.9 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