Variable Declarations in JS

JavaScript performance comparison

Test case created

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
Declare First
var L = 100000;
while (L--) {
  var x, y, z, a, b, c;
  if (1 == 2) {
    x = 6;
  }
}
pending…
Declare As Needed
var L = 100000;
while (L--) {
  var y;
  if (1 == 2) {
    var x = 6,
        z = 10,
        a = 1,
        b = 2,
        c = 4;
  }
}
pending…

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

Compare results of other browsers

1 comment

Zoltán Mihályi commented :

This test is unusable because of the "variable hoisting"

Add a comment