Run details:
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:68.0) Gecko/20100101 Firefox/68.0
Firefox 68
Ubuntu
Desktop
3 years ago
Test name Executions per second
[...Array(n).keys()].map(k => undefined) 85.8 Ops/sec
Array.apply(null, { length: 4 }) 128.0 Ops/sec
Array.from 112.2 Ops/sec
Array(n).fill(undefined) 388.4 Ops/sec
for loop push 111.3 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