declaring variable in loop or outside (v2)

Revision 2 of this benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
Declare variables before the loop
var i = 0,
    j = 0,
    p = 1;
for (; i < 1000; i++) {
  for (; j < 1000; j++) {
    p = i + j;
  }
}
ready
Declare variables inside the loop
var p = 1;
for (var i = 0; i < 1000; i++) {
  for (var j = 0; j < 1000; j++) {
    p = i + j;
  }
}
ready

Revisions

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