“Double Quotes” vs ‘Single Quotes’ vs `Backticks` in JavaScript

Difference Between using ‘Single Quotes’, “Double Quotes”, and `Backticks` in JavaScript Strings.

Chameera Dulanga
Bits and Pieces
Published in
5 min readJun 15, 2021

--

In JavaScript, single quotes (‘’) and double quotes (“”) are used to create string literals. Most developers use single or double quotes as they prefer, and sometimes they let their code formatters decide what to use.

So, I wanted to find the real difference between these 2, and this article will discuss similarities, differences, and essential tips you should remember while using these quotes.

‘Single Quotes’ vs. “Double Quotes”

As I mentioned, both of these are used to create string literals (values) in JavaScript, and they act in exactly the same way.

The only noticeable difference between single quotes and double quotes comes into play when we have to escape characters.

If you use single quotes to create a string, you can not use single quotes within that string without escaping them using a backslash (\).

The same theory applies to double quotes, and you have to use a backslash to escape any double quotes inside double quotes.

However you can use single quotes inside double quotes or double quotes inside single quotes without escaping.

I personally prefer to use double quotes to create strings in JavaScript. It makes strings more readable since we don't use backslashes.

Are There Any Alternatives?

--

--