Run details:
Mozilla/5.0 (Android 10; Mobile; rv:101.0) Gecko/101.0 Firefox/101.0
Firefox Mobile 101
Android
Mobile
2 years ago
Test name Executions per second
for 7982599.5 Ops/sec
foreach 4712518.5 Ops/sec
some 4714775.0 Ops/sec
for..of 483009.4 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];
    }