You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This article presents some good argument against doing it that way . I agree with almost everything in this article; except I don't believe single var statement is more readable.
When I read the examples on my phone, the four spaces indent didn't cause alignment with "var " due to proportional fonts. Perhaps tabs would have been better ;)
You did raise a good point there; I'm not a fan of lining up wrapped line alignment, partly for that reason. My general rule for wrapped lines is 2 x indentation.
Yeah, I'd say multiple var declarations are actually preferable - changes to them diff better, for one. That said, I wouldn't want to prohibit single var declarations. They can be useful if you want to declare, but not assign, a series of variables on a single line, e.g., var x, y, z;.
Also, I really don't think it's necessary to put all of a scope's variable declarations at the top. Sometimes a variable only makes sense for a particular block further down, in which case putting at the top is just noise. JS developers ought to know about var hoisting, and the consequences of it.
Activity
jaraco commentedon Mar 31, 2014
When I read the examples on my phone, the four spaces indent didn't cause alignment with "var " due to proportional fonts. Perhaps tabs would have been better ;)
var\tfoo;
\tbar;
Jk
Sent from my comm
On Mar 31, 2014, at 21:36, "Berry Phillips" <notifications@github.commailto:notifications@github.com> wrote:
The guide is in favor of declaring multiple variables with only 1 var statement. For example:
var items = getItems(),
goSportsTeam = true,
dragonball = 'z';
Here's a good argument for this issue http://benalman.com/news/2012/05/multiple-var-statements-javascript/. I agree with almost everything in this article; except I don't believe single var statement is more readable.
Reply to this email directly or view it on GitHubhttps://github.com//issues/1.
berryp commentedon Mar 31, 2014
Well, if you used a "proper" phone...
You did raise a good point there; I'm not a fan of lining up wrapped line alignment, partly for that reason. My general rule for wrapped lines is 2 x indentation.
markrian commentedon Apr 1, 2014
Yeah, I'd say multiple var declarations are actually preferable - changes to them diff better, for one. That said, I wouldn't want to prohibit single var declarations. They can be useful if you want to declare, but not assign, a series of variables on a single line, e.g.,
var x, y, z;.Also, I really don't think it's necessary to put all of a scope's variable declarations at the top. Sometimes a variable only makes sense for a particular block further down, in which case putting at the top is just noise. JS developers ought to know about var hoisting, and the consequences of it.