Script Preparation code:
AخA
 
var n = 100000; // 100k
function filler(v, i) {
    return i ** 2;
}
Tests:
  • Spread operator

     
    [...Array(n).keys()].map(filler);
  • Array apply

     
     Array.apply(null, { length: n }).map(filler);
  • Array from

     
    Array.from({ length: n }, filler);
  • Array fill

     
    Array(n).fill(undefined).map(filler)
  • For loop push

     
    const arr = [];
    for (let i = 0; i < n; i++) {
      arr.push(filler(null, i));
    }
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    Spread operator
    Array apply
    Array from
    Array fill
    For loop push

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 5 months ago)
Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Mobile Safari/537.36
Chrome Mobile 130 on Android
View result in a separate tab
Test name Executions per second
Spread operator 91.7 Ops/sec
Array apply 128.4 Ops/sec
Array from 119.8 Ops/sec
Array fill 224.9 Ops/sec
For loop push 235.3 Ops/sec