Run details:
Mozilla/5.0 (Android 11; Mobile; rv:102.0) Gecko/102.0 Firefox/102.0
Firefox Mobile 102
Android
Mobile
2 years ago
Test name Executions per second
for 9001550.0 Ops/sec
foreach 5274473.0 Ops/sec
some 5240590.5 Ops/sec
for..of 528341.6 Ops/sec
Script Preparation code:
AخA
 
var array = new Array(100);
Tests:
  • for

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

     
    array.forEach(function(i) {
      array[i];
    });
  • some

     
    array.some(function(i) {
      array[i];
    });
  • for..of

     
    for (var i of array) {
      array[i];
    }