Run details:
Mozilla/5.0 (Linux; Android 9; SAMSUNG SM-G611MT) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/16.2 Chrome/92.0.4515.166 Mobile Safari/537.36
Chrome Mobile 92
Android
Mobile
3 years ago
Test name Executions per second
for loop 14278.3 Ops/sec
reverse while loop 14233.9 Ops/sec
Script Preparation code:
AخA
 
var array = [];
(function () {
  var length = 100;
  while (length--) {
    array.push(Math.random());
  }
})();
Tests:
  • for loop

    x
     
    var i = 0;
    var length = array.length;
    for (; i < length; i++) {
      array[i]++;
    }
  • reverse while loop

     
    var i = array.length;
    while (i--) {
      array[i]++;
    }