Can anyone tell me why use one var declaration for multiple variables and declare each variable on a newline consider is a good programming behavior?
var items = getItems();
var goSportsTeam = true;
var dragonball = 'z';
var items = getItems(),
goSportsTeam = true,
dragonball = 'z';
It is not considered 'good' or 'bad'. It's a matter of preference.
The guy who built the code quality tool JSLint, Douglas Crockford likes it.
var declarations move to the top of their scope automatically.
Here is why Crockford thinks the second option is better: