Escape sequences on JavaScript string literals
- Last Updated: October 24, 2025
- 1 minute read
- Corticon.js
- Documentation
A character preceded by a backslash (\) is an escape sequence and has special meaning to the compiler. The following table shows the JavaScript escape sequences:
| Escape Sequence | Description |
| \t | Insert a tab in the text at this point. |
| \b | Insert a backspace in the text at this point. |
| \n | Insert a newline in the text at this point. |
| \r | Insert a carriage return in the text at this point. |
| \f | Insert a form feed in the text at this point. |
| \' | Insert a single quote character in the text at this point. |
| \" | Insert a double quote character in the text at this point. |
| \\ | Insert a backslash character in the text at this point. |
When an escape sequence is encountered in a print statement, the compiler interprets it accordingly. For example, if you want to put quotes within quotes you must use the escape sequence, \", on the interior quotes.
JavaScript specifics:
- Template Literals: JavaScript's template literals (backticks ``) introduce
additional escaping rules for embedded expressions (
${}) and backticks themselves (\` `). - Vertical Tab (
\v): While both support\v, older versions of Internet Explorer might interpret it as a literal 'v' instead of a vertical tab, making\x0Ba more robust cross-browser alternative. - Null Character (
\0): JavaScript's\0represents the null character (U+0000) only if the next character is not a decimal digit; otherwise, it's interpreted as an octal escape sequence. - Unicode Escapes: Both support Unicode escapes, but JavaScript also allows for
extended Unicode escape sequences using curly braces, e.g.,
\u{1F600}for emojis.