Learning JS. String
s can be represented with either single quotes or double quotes and I’m wondering if there is any functional difference. Is there no such thing as a char
in this language that needs to be used with single quotes? It seems as if the primitive data type is the String
.
You are correct about there being no char
in JS, only string
. The quotes have no functional difference. Where we might want to use both, one as an outer pair, and one as an inner pair is if the string contains a quote.
As of ES2015 we also have string template literals which are denoted by backticks. Those all also legal quotes for all intents and purposes.
Given that advantage, it makes escapement a thing of the past.
3 Likes