multiple vs single var declarations

JavaScript performance comparison

Revision 2 of this test case created by deVars


added arrays and objects in the mix

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
single var
var foo = 'foo',
    bar = 'bar',
    baz = 42,
    fooObj = {foo: 'foo', baz: 1, bar: ['baz', 'bar']},
    fooArr = ['foo', 'baz', 1, {bar: 'bar'}];
multiple var
var foo = 'foo';
var bar = 'bar';
var baz = 42;
var fooObj = {foo: 'foo', baz: 1, bar: ['baz', 'bar']};
var fooArr = ['foo', 'baz', 1, {bar: 'bar'}];

Compare results of other browsers


You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:


Comment form temporarily disabled.

Add a comment