Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comma-first vars should be encouraged. #195

Open
programmin1 opened this issue Jul 9, 2015 · 4 comments
Open

Comma-first vars should be encouraged. #195

programmin1 opened this issue Jul 9, 2015 · 4 comments

Comments

@programmin1
Copy link

It says "Any project that cites this document as its base style guide will not accept comma first code formatting", yet I have found comma-first is the best way if you don't want multiple var statements

For example:

var a=1,
      b=3
      c=4

will easily make a global variable c, which is likely not intended.

This style:

var a=1
,   b=3
,   c=4

is more obvious when a comma is missing - causing a global variable to be created.

@acconrad
Copy link

acconrad commented Jul 9, 2015

While I agree that it is clearer and easier to find missing commas, this is not a universally accepted axiom of the JS community. Plus, there are even differences in opinion within the pro-comma group. I'd argue that the odd spacing would be cumbersome and just easier to write:

var a = 1
  , b = 2
  , c = 3;

and I'd include spaces between = as well.

So as much as I like comma-first, I can't say that as a whole Idiomatic should be evangelizing such a polarizing style.

@leonardolessa
Copy link

Well, in my case I believe both are bad options, I think multiple var statements is the way to go, Ben Alman post cleared my mind. And like him, I've never heard a clear case that a single var statement is better than multiple despite being "pretty".

@LiamKenneth
Copy link

I agree with @leonardolessa, here is a good article about not using single var.

@stegano
Copy link

stegano commented May 4, 2016

I agree with @leonardolessa @LiamKenneth, because programmers are not minimizer&optimizer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants