Tutorial
Escape Characters

Escape Characters in JavaScript

🎉

Read This on Github

This article is available on Github. You can read it there and contribute to it.
Github Link
Any Issue ?

⭐ Escape Character

Explanation of Escape Character

In JavaScript, an escape character is a character that is used to represent a character that cannot be typed directly from the keyboard. Escape characters are typically used to specify special characters in a string, such as newlines, tabs, and quotation marks.

There are several escape characters in JavaScript that can be used in strings. Here is a list of some of the most commonly used escape characters:

Escape CharacterDescription
\'Single quote
\"Double quote
\\Backslash
\bBackspace
\fForm feed
\nNewline
\rCarriage return
\tTab
\vVertical tab
let str = 'This string includes all of the escape characters: \', \", \\, \b, \f, \n, \r, \t, and \v';
console.log(str);
// Output: "This string includes all of the escape characters: ', ", \, \b, \f, \n, \r, \t, and \v"

The \' escape character is used to insert a single quote, the \" escape character is used to insert a double quote, the \\ escape character is used to insert a backslash, the \b escape character is used to insert a backspace, the \f escape character is used to insert a form feed, the \n escape character is used to insert a newline, the \r escape character is used to insert a carriage return, the \t escape character is used to insert a tab, and the \v escape character is used to insert a vertical tab.

⚡ Playground