Run details:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36
Chrome 76
Linux
Desktop
5 years ago
Test name Executions per second
for loop 60123.8 Ops/sec
reverse while loop 59597.1 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]++;
    }