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

67

u/[deleted] Apr 01 '18

"Being same as C++" should be quite low in priority for a JavaScript style guide.

One reason why single quotes is no shift. It's faster to type, and who cares what it is, anyway, as long as it's consistent.

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/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 :)