Run details:
Mozilla/5.0 (Linux; Android 7.1.2; Redmi 5 Build/N2G47H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.91 Mobile Safari/537.36
Chrome Mobile 68
Android 7.1.2
Mobile
6 years ago
Test name Executions per second
for 9053.8 Ops/sec
foreach 410118.8 Ops/sec
some 407895.1 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];
    });