JS Bytes : ‘’ vs “” vs ``

You’ve probably seen both single quotes and double quotes used in JavaScript. I wondered when I should be using single quotes ‘’ vs double quotes “” vs backticks `` in my code and wanted to share that info with the other wonderers out there.

Single quotes and double quotes behave in exactly the same way in JavaScript.

The most important thing is to be consistent with your use of single vs double quotes.

If you’re a stickler for convention, I would read and follow Airbnb’s style guide regarding strings.

Backticks aka “template literals” aka “template strings” aka “fancy strings” were introduced in the ES2015 specifications. MDN states “ Template literals are string literals allowing embedded expressions. You can use multi-line strings and string interpolation features with them. They were called “template strings” in prior editions of the ES2015 specification”.

Backticks are commonly used for multi-line strings or when you want to interpolate an expression within your string.