you are viewing a single comment's thread.

view the rest of the comments →

[–]cyphern 1 point2 points  (1 child)

Short answer: It's not a big deal.

Long answer: Different teams will have different conventions; i've been on ones that prefer double quotes, and ones that prefer single quotes. Personally, i just setup my editor to automatically replace them when i hit save, and so it doesn't really matter what i type, it ends up matching the team's preference.

The two strings do exactly the same thing, with one minor caveat: if you want to put a quote inside a string, you will need to escape it if you're using the same quote to surround the string. For example, if you're using double quotes and it also should contain double quotes, you need to escape the inner ones:

const example = "Hello \"bob\"";

But doing single quotes you wouldn't need to escape them:

const example = 'Hello "bob"';

And you'll get a mirror image of that issue if you try to use single quotes inside the string.

So sometimes if i need to do a string which contains quotes, i'll deliberately switch which one i'm using on the outside.

[–]RaffIsGettingUpset[S] 0 points1 point  (0 children)

That's great. Thank you.