I am using TypeScript for Angular and I've noted that there are some places where we only use ' ' and in others only " ".
What's the difference?
Asked
Active
Viewed 394 times
-1

Manu__A
- 1
- 3
2 Answers
0
These are js string literals. the only difference is that inside " " string single' are auto-escaped and vise versa, inside of ' ' string double" are auto-escaped.
Usually single quotes are preferred in js, and even there is a popular eslint rule that enforces single quotes usage
-
They aren't "autoescaped". They *do not need escaping*. The string `"a"` doesn't "autoescape" the character `a`. Same with the string `"'"` - the character `'` is just a normal character. – VLAZ Jul 31 '21 at 10:46
-
"*usually single quotes are more preffered in js, and even there is a popular eslint rule that enforces single quotes usage*" the [popular ESLint rule](https://eslint.org/docs/rules/quotes) enforces one style of quotes. Of your choice. Not "single quotes". Also, the default config value is `"double"`. – VLAZ Jul 31 '21 at 10:48
0
There's no difference except that "
can be used without escaping it in a string defined with '
and the same for '
in a string defined with "
.
Both define a Typescript string
.

Gaël J
- 11,274
- 4
- 17
- 32