Script Preparation code:
AخA
 
var testingArray = new Array(1000).fill(1);
Tests:
  • For i

    x
     
    const newArr = [];
    for (let i = 0, item; (item = testingArray[i]); i += 1) {
      newArr.push(item);
    }
  • For of

     
    const newArr = [];
    for (const item of testingArray) {
      newArr.push(item);
    }
  • ForEach

     
    const newArr = [];
    testingArray.forEach(item => {
      newArr.push(item);
    });
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    For i
    For of
    ForEach

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 4 years ago)
Mozilla/5.0 (Macintosh; Intel Mac OS X 11_2_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.82 Safari/537.36
Chrome 89 on Mac OS X 11.2.2
View result in a separate tab
Test name Executions per second
For i 10608.9 Ops/sec
For of 184306.3 Ops/sec
ForEach 148914.5 Ops/sec