Script Preparation code:
AخA
 
const arrNested = Array.from(Array(1000).keys());
const arr = new Array(1000).fill(null).map((item) => ({
    nested: [...arrNested],
}));
Tests:
  • spread

     
    const resultSpread = [];
    arr.forEach((item) => {
        resultSpread.push(...item.nested);
    });
  • forEach push

    x
     
    const resultNestedLoop = [];
    arr.forEach((item) => {
        item.nested.forEach((nestedItem) => resultNestedLoop.push(nestedItem));
    });
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    spread
    forEach push

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 29 days ago)
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36
Chrome 133 on Mac OS X 10.15.7
View result in a separate tab
Test name Executions per second
spread 372.1 Ops/sec
forEach push 266.9 Ops/sec