Script Preparation code:
AخA
 
   var arr = [];
    for (var i = 0; i < 1000; i++) {
      arr[i] = i;
    }
  
    function someFn(i) {
      return i * 3 * 8;
    }
Tests:
  • foreach

     
    arr.forEach(item => someFn(item))
  • for

     
    for (let i = 0; i < arr.length; i++) {
      someFn(arr[i])
    }
  • for_of

     
    for (const item of arr) {
      someFn(item)
    }
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    foreach
    for
    for_of

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 2 years ago)
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:99.0) Gecko/20100101 Firefox/99.0
Firefox 99 on Mac OS X 10.15
View result in a separate tab
Test name Executions per second
foreach 138386.6 Ops/sec
for 782708.9 Ops/sec
for_of 141272.2 Ops/sec