Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36
Chrome 88
Windows
Desktop
4 years ago
Test name Executions per second
simple reverse for 60384.9 Ops/sec
reverse while 61090.5 Ops/sec
for-push 31117.5 Ops/sec
for 31513.5 Ops/sec
reverse for 46105.9 Ops/sec
Script Preparation code:
AخA
 
let size = 100;
let indices = [];
Tests:
  • simple reverse for

    x
     
    indices = [], size = 100;
    for (i = size; i--; ) {
        indices[i] = i;
    }
  • reverse while

     
    indices = [],   i = size;
    while (i--) indices[i] = i;
  • for-push

     
    indices = [];
    for (i = 0; i <= size; i++) {
        indices.push(i);
    }
  • for

     
    indices = [];
    for (i = 0; i < size; i++) {
      indices[i] = i;
      }
  • reverse for

     
    indices = [];
    for (i = size; i > -1; i--) {
        indices[i] = i;
    }