for loop with length in first statement

Benchmark created on


Setup

var sum = 0;
    var a = [];
    var i = 10000;
    while (i--) {
      a.push(2);
    }

Test runner

Ready to run.

Testing in
TestOps/sec
l in 1st
for (var i = 0; i < a.length; i++) {
  sum += a[i];
}
ready
l in 2nd
for (var i = 0, l = a.length; i < l; i++) {
  sum += a[i];
}
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.