Skip to content

Challenge Quoting Strings With Single Quotes

Quincy Larson edited this page Aug 20, 2016 · 1 revision

Challenge Quoting Strings with Single Quotes

String values in JavaScript may be written with single or double quotes, so long as you start and end with the same type of quote. Unlike some languages, single and double quotes are functionally identical in Javascript.

"This string has \"double quotes\" in it"

The value in using one or the other has to do with the need to escape quotes of the same type. If you have a string with many double quotes, this can be difficult to read and write. Instead, use single quotes:

'This string has "double quotes" in it. And "probably" lots of them.'

Clone this wiki locally