3 ms·
With separate var statements, you never end up with this situation: var foo = 1, bar = 2 baz = 3 In 90% of the cases the code will run the
by mnutt 14y ago
With separate var statements, you never end up with this situation:
var foo = 1,
bar = 2
baz = 3
In 90% of the cases the code will run the same whether or not there is a comma on line 2, but in the other 10% you will get burned in odd ways now that `baz` is a global variable.
- Isofarro 14y agoJS Lint is your friend in this case. It will log that * There's a missing semicolon on line 2 * There's a missing semicolon on line 3 * baz was being used before it was defined. That's just in a global context. When it's in a function you get a little more: * the baz line is indented too far - because it's being interpreted as a new statement. Sure, you could eyeball your code looking for this. Or just use an automated tool that'd do it for you