EN
JavaScript - escape characters in string
0 points
In this article, we would like to show you escape characters and how to insert them into the string in JavaScript.
Quick solution:
xxxxxxxxxx
1
const text = 'Hello\tWorld!';
2
3
console.log(text); // Hello World!
In this example, we use backslash to escape double quotation marks and create a quote inside the text
string.
xxxxxxxxxx
1
const text = "\"This is my quote.\"";
2
3
console.log(text); // Hello World!
escape character | result |
---|---|
\' |
single quote |
\\ | backslash |
\n | new line |
\t |
tab |
\b | backspace |
\r | carriage return |
\f | form feed |
\ooo | octal value |
\xhh | hex value |