Javascript Reference
Categories: Operators

javascript Operators /char

@July 3, 2008, 3:43 p.m.
/char Firefox/Netscape/NN 2 IE 3 ECMA 1  

 

  

JavaScript provides a mechanism for including common whitespace characters (sometimes called control codes) inside strings, as well as symbols that otherwise conflict with string representation. The key is the backslash character (\), followed immediately by a single character with a special meaning. The following table shows the recognized escaped characters and their meanings.

 

These characters come in handy for alert, confirm, and prompt dialog box text. For example, if you want to display multiple paragraphs with a blank line between them in an alert box, you would insert line feed characters:

alert("First paragraph.\n\nSecond paragraph.")
 

Note that these characters apply to strings, and do not influence HTML content formatting for carriage returns.

 
Escape sequence Description
\b Backspace
\t Horizontal tab
\n Line feed (new line)
\v Vertical tab
\f Form feed
\r Carriage return
\" Double quote "
\' Single quote '
\\ Backslash

Powered by Linode.