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

24

u/e_man604 Apr 01 '18

Why is single quote (') preferred over double quote (") ? For me it makes sense to use double to remain same when dealing with c++ for instance.

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.

1

u/JESUSgotNAIL3D Apr 01 '18

Ahhhhh damn. I like keeping my double quotes from C++ (new JS guy here). Looks like I'll join the single quote crowd if that's preferred in the community.... damn!

1

u/tencircles Apr 02 '18

it's definitely not "preferred". People who use them are very vocal about it though. I haven't seen anything indicating that single quotes are preferred.

1

u/JESUSgotNAIL3D Apr 03 '18

If you look at most of the replies to the OP (in this comment chain I mean), a lot of people say single is more common than double.

I'm still on the fence with this but for now I'll use single and set Prettier up to do the same so it's not a big deal.

Tabs though.... now that's an easy decision. 4 space indents and I'm golden, no fence there.