Run details:
Mozilla/5.0 (Linux; Android 11) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.120 Mobile Safari/537.36
Chrome Mobile 91
Android
Mobile
3 years ago
Test name Executions per second
[...Array(n).keys()].map(k => undefined) 47.9 Ops/sec
Array.apply(null, { length: 4 }) 280.9 Ops/sec
Array.from 47.3 Ops/sec
Array(n).fill(undefined) 973.7 Ops/sec
for loop push 37.5 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