Script Preparation code:
Tests:
  • [...Array(n).keys()].map(k => undefined)

  • Array.apply(null, { length: 4 })

  • Array.from

  • Array(n).fill(undefined)

  • for loop push

Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results
  • Test case name Result
    [...Array(n).keys()].map(k => undefined)
    Array.apply(null, { length: 4 })
    Array.from
    Array(n).fill(undefined)
    for loop push

    Fastest: N/A

    Slowest: N/A

Get performance results from real users on your website with Request Metrics.
Latest run results:
Run details: (Test run date: 8 hours ago)
Mozilla/5.0 (Android 14; Mobile; rv:124.0) Gecko/124.0 Firefox/124.0
Firefox Mobile 124 on Android
View result in a separate tab
Test name Executions per second
[...Array(n).keys()].map(k => undefined) 396.8 Ops/sec
Array.apply(null, { length: 4 }) 379.4 Ops/sec
Array.from 605.4 Ops/sec
Array(n).fill(undefined) 1959.6 Ops/sec
for loop push 1251.0 Ops/sec