Skip to content

Conversation

paultannenbaum
Copy link

Per @bdoms suggestion of being explicit on variable declarations.

Article @bdoms referenced: http://benalman.com/news/2012/05/multiple-var-statements-javascript/

I also had the ingenious idea of pushing this to airBnB (by accident), and we got some nice feedback from a couple of their engineers as well: airbnb#143

@doomspork @GabKlein @amdtech @jmacadam @jcarouth feel free to debate if you want. I am neutral on this one.

@bdoms
Copy link

bdoms commented Feb 7, 2014

Looks good to me! Anybody else have other thoughts?

@@ -368,18 +368,19 @@
var superPower = new SuperPower();
```

- Use one `var` declaration for multiple variables and declare each variable on a newline.
- Use `var` declaration for each new variable. This prevents us to have to worry about formatting and is more explicit.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might want to revisit this sentence: "This prevents us to have to worry about formatting and is more explicit"

@paultannenbaum
Copy link
Author

@doomspork or @bdoms Please review and merge if happy.

@@ -397,7 +398,7 @@
len;

// good
var items = getItems(),
var items = getItems(),
goSportsTeam = true,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this example also be changed to match the new style above?

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

Successfully merging this pull request may close these issues.

3 participants