Case 1:
var x = null;
var y = 1;
var z = "hello";
Case 2:
var x = null, y = 1, z = "hello"
Are there any performance difference between the two? Or what's the difference?
Case 1:
var x = null;
var y = 1;
var z = "hello";
Case 2:
var x = null, y = 1, z = "hello"
Are there any performance difference between the two? Or what's the difference?
Just writing style. No difference.
At a very fine level, maybe there will be some tokenising difference, but it should not (or rather would not) be a predictable performance variation as it depends on the interpreter/tokeniser implementation or design!!
From my experience, I think you have way more important things than declaration style to worry about for performance tweaking.
They are equivalent and there ought to be no difference in performance although that could be down to the Javascript interpreter.
The first way (i.e. three separate statements) is certainly clearer.
None at all it's just a preference; if you are running JsLint it will recommend chaining them together where possible.
http://davidshariff.com/blog/chaining-variable-assignments-in-javascript-words-of-caution/
This is a great blog about variable chaining.
I think there is no real difference between yours two way to do.
If you want a proper code, i think the first is the best, otherwise, the other make you win 2 lines. :)