Skip to content

Variable declaration #143

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

Closed
wants to merge 2 commits into from

Conversation

paultannenbaum
Copy link

@bdoms @doomspork @jcarouth @amdtech

Per @bdoms suggestion to be explicit about variable declaration. This article was referenced and has some valid poiints: http://benalman.com/news/2012/05/multiple-var-statements-javascript/

Im neutral, and mainly just want to decide on one standard.

@nmussy
Copy link
Contributor

nmussy commented Feb 6, 2014

I'm not sure either. Just the fact that, as the article said, Multiple var statements are noobish, or at least look like it, seems bigger than all the little points he raises. It's probably one of the first things I look on a JavaScript file by a dev whose skill I'm not sure of.

Oh, and be careful, your 661cfe1 commit changes the name of the guide.

@yaroslavya
Copy link

I dont get it. If you use the var all the time - you cant end with global. If you use commas you can make variable global. And develop a habbit to use var is easier, than to develop a habbit to check if it is a declaration and you are not going to break it. Couple of situations:

  • I have a habbit to use var whenever I introduce a variable. Its something you can check easilly, is there a var before the variable declaration? Yes = its ok. And common IDE can get you to declaration.
  • If I use comma, I have to make sure I go back all the way to the var and then forward to my changes, to make sure I didnt break anything. It seems something harder to check and more error prone as more entities involved, especially in case theres big list of variables.

I also heard this statement as the way to advocate commas:

You should not have long list of arguments in a function and a long function.
Agree, but what if someone else authored the code? Its quite possible, that person followed the "comma way" of variable declaration. In this quite possible case you have a code, that require more brain effrots to maintain.

Not sure if it is the right place to put it.

@doomspork
Copy link

Apologizes all, you can close this Pull Request. This was inadvertently against your master and not our fork.

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

Successfully merging this pull request may close these issues.

6 participants