Run details:
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:63.0) Gecko/20100101 Firefox/63.0
Firefox 63
Ubuntu
Desktop
6 years ago
Test name Executions per second
for 1113086.2 Ops/sec
foreach 7774142.0 Ops/sec
some 8024748.0 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(item, index) {
      return item;
    });
  • some

     
    array.some(function(item, index) {
      return item === array[index];
    });