Run details:
Mozilla/5.0 (iPhone; CPU iPhone OS 16_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.1 Mobile/15E148 DuckDuckGo/7 Safari/605.1.15
Mobile Safari 16
iOS 16.1
Mobile
2 years ago
Test name Executions per second
[...Array(n).keys()].map(k => undefined) 49.7 Ops/sec
Array.apply(null, { length: 4 }) 0.0 Ops/sec
Array.from 40.1 Ops/sec
Array(n).fill(undefined) 5804.2 Ops/sec
for loop push 36.1 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