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

Show parent comments

3

u/tencircles Apr 01 '18

It's faster to type

Not really, though I hear this argument all the time. Your pinky rests on the shift key. A isn't slower to type than a (or shouldn't be). The reason to prefer double quotes is to keep consistency with JSON, HTML, and other languages. Personally I prefer backtick to both because it's simply cleaner in a lot of cases. Historically the argument for single quotes was so that you didn't have to escape double quotes in your html strings when writing jQuery apps, but that doesn't really apply in modern JS dev.

18

u/[deleted] Apr 01 '18

Your pinky rests on the shift key.

No, that's not where my pinky rests.

https://en.wikipedia.org/wiki/Touch_typing#/media/File:QWERTY-home-keys-position.svg

1

u/web__dev Apr 02 '18

That's what I was thinking. They call it "home row" for a reason.

1

u/tencircles Apr 02 '18

which was developed and designed for the english language, not javascript/programming which has a completely different set of concerns/common keys.

1

u/tencircles Apr 02 '18

Why would you use home keys position when programming? Half of the things you're doing involve hotkeys, some combination of a key with Ctrl, alt, cmd, or shift. I get it if you're editing a word document, but practically placing your fingers like this when programming is just a hindrance.

From pinky to index -> shift | a | z | cmd. If you're actually worried about saving yourself time/keystrokes, this will save you a hell of a lot more time than worrying about a shift press (which is by far the most common action which requires two key presses).

1

u/[deleted] Apr 03 '18

Half the things I'm doing are hotkeys? That's not my experience.

But you keep doing whatever suits you :)

1

u/Flyen Apr 01 '18

I use the home keys when typing a document, but when coding, there's a lot more {}()<>_-\ use, so my fingers are in a different place.

0

u/[deleted] Apr 01 '18

[deleted]

6

u/Vlad210Putin Apr 01 '18

Single quotes is also the JS standard.

Source?

JS has no standard. That's why these ridiculous arguments keep happening.

0

u/[deleted] Apr 02 '18

[deleted]

5

u/planetary_pelt Apr 02 '18

that's just a style guide that's cheekily named "standard."

if someone is referring to that when they say "the JS standard," then they are clearly confused about the relationship between that style guide and JS.