Run details:
Mozilla/5.0 (Android 11; Mobile; rv:90.0) Gecko/90.0 Firefox/90.0
Firefox Mobile 90
Android
Mobile
3 years ago
Test name Executions per second
for 7651896.0 Ops/sec
foreach 4815155.5 Ops/sec
some 4810188.5 Ops/sec
for..of 435855.2 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];
    }