r/javascript • • Apr 01 '18

Google publishes a JavaScript style guide. Here are some key lessons.

https://medium.freecodecamp.org/google-publishes-a-javascript-style-guide-here-are-some-key-lessons-1810b8ad050b
714 Upvotes

317 comments sorted by

View all comments

81

u/tencircles Apr 01 '18

I don't get the 2 spaces thing. It makes code harder to read. 4 is best. Don't even @ me.

25

u/rafalg Apr 01 '18

I don't get it either. Combined with the rules regarding curly braces it makes some places in code look like solid blocks of text.

if (something) {
  doThis();
} else if (somethingElse) {
  doThat();
} else if (somethingElse2) {
  foo();
}

It sucks how text on every line except for the first one starts in the same column.

11

u/a_tocken Apr 02 '18

Looks clear to me but then I use 2-space tabs outside of work.

0

u/[deleted] Apr 02 '18

[deleted]

1

u/a_tocken Apr 04 '18

The Google style guide for Java, which is generally pretty sane, recommends braces always because it is harder to mess up. I think this is more true for teams rather than solo users. I favor braces but I will make exceptions to the rule.

→ More replies (7)