4 ms·
Other than style, is there an advantage to either of them over just declaring each one separately? var variable; var anotherVariable; var thirdVariable;
by mnutt 16y ago
Other than style, is there an advantage to either of them over just declaring each one separately?
var variable;
var anotherVariable;
var thirdVariable;
One issue I see with multiple variable declarations is that a forgotten comma doesn't cause a syntax error, it just causes that variable and any after it to be global variables. Which leads to much nastier javascript bugs.
- jacobolus 16y agoFor Node code, not really. For browser code, usually not really, but for high traffic sites or widely used libraries every character counts.