Run details:
Mozilla/5.0 (Linux; arm_64; Android 9; SM-A505FM) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.97 YaBrowser/19.12.1.121.00 Mobile Safari/537.36
Yandex Browser 19
Android
Mobile
5 years ago
Test name Executions per second
for 27434.5 Ops/sec
foreach 1077224.4 Ops/sec
some 1058911.4 Ops/sec
for..of 44474.8 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];
    }