SiteMap  | About    

JavaScript Escape Characters

An escape character enables you to output characters you wouldn't normally be able to, usually because the browser will interpret it differently to what you intended.


When you run the above code, it will end in an error because the browser encounters the first double quote , it will think that the string has finished.

Using escape character

The above code will run successfully, because the browser encounters the backslash , it knows not to try to interpret the next character.

JavaScript uses the \(backslash) as an escape characters for:

  1. \' single quote

  2. \" double quote

  3. \ backslash

  4. \n new line

  5. \r carriage return

  6. \t tab

  7. \b backspace

  8. \f form feed

  9. \v vertical tab (IE < 9 treats '\v' as 'v' instead of a vertical tab ('\x0B'). If cross-browser compatibility is a concern, use \x0B instead of \v.)

  10. \0 null character (U+0000 NULL) (only if the next character is not a decimal digit; else it’s an octal escape sequence) (C) 2017    Founded by raps mk
All Rights Reserved. All other trademarks are property of their respective owners.