Multiple var versus single var statements

JavaScript performance comparison

Test case created by BrynM

Info

Code style aside, is there any performance difference?

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
multiple var statements
var a = 1;
var b = "b";
var c = true;
var d = null;
var e;
var f = undefined;
var g = [];
var h = new Array();
var i = {};
pending…
single declaration, multi-line statement
var a = 1
  , b = "b"
  , c = true
  , d = null
  , e
  , f = undefined
  , g = []
  , h = new Array()
  , i = {};
pending…
single declaration, multi-line statement (non-comma first)
var a = 1,
  b = "b",
  c = true,
  d = null,
  e,
  f = undefined,
  g = [],
  h = new Array(),
  i = {};
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

0 comments

Add a comment