Script Preparation code:
AخA
 
var array = Array.from({length: 100});
var t;
Tests:
  • for

     
    for (let i = 0; i < array.length; i++) {
      t = array[i];
    }
  • foreach

     
    array.forEach(function(v, i) {
      t = v;
    });
  • for..of

     
    for (var v of array) {
      t = v;
    }
  • for..of over entries

     
    for (var [i, v] of array.entries()) {
      t = v;
    }
  • for..in

     
    for (var k in array) {
      t = array[k];
    }
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    for
    foreach
    for..of
    for..of over entries
    for..in

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 7 days ago)
Mozilla/5.0 (iPhone; CPU iPhone OS 18_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.1 Mobile/15E148 Safari/604.1
Mobile Safari 18 on iOS 18.1
View result in a separate tab
Test name Executions per second
for 28145284.0 Ops/sec
foreach 14462594.0 Ops/sec
for..of 10457642.0 Ops/sec
for..of over entries 1161500.4 Ops/sec
for..in 1201672.1 Ops/sec