Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:121.0) Gecko/20100101 Firefox/121.0
Firefox 121
Windows
Desktop
11 months ago
Test name Executions per second
[...Array(n).keys()].map(k => undefined) 431.5 Ops/sec
Array.apply(null, { length: 4 }) 342.5 Ops/sec
Array.from 738.8 Ops/sec
Array(n).fill(undefined) 1294.0 Ops/sec
for loop push 1978.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