The Escape Sequences for JavaScript Strings

Go Directly To: Escape Sequence Reference Table

Description

The term "escape sequences" is also referred to as "inline characters". Escape sequences are generally of two types. There are the invisible characters (tabs, carriage return, new line and form feed) that render an action as opposed to a visual affect. Then, there are the string related characters that allow special characters to be inserted into the string. These characters need special handling because they can be confused with the JavaScript language syntax (double and single quotes, backslash, etc.).

When a backslash (\) is encountered in a string of characters, the next character is combined with the backslash to form an escape sequence. The JavaScript interpreter allows an escape from the normal interpretation of the character and performs an entirely different operation ("\n" will give you a newline, not the character "n" or "\n"). A backslash preceding any character not in this set is ignored by the interpreter.

An escape sequence can be represented in generic formats. Latin-1 and Unicode characters can be specified with hexadecimal numbers.


Escape Sequence Reference Table


Escape Sequence Reference Table
Sequence Alternate Codes Character Represented Sequence Description
Latin-1 Unicode
Footnotes: The first 256 characters within the Unicode Standard comprise the Latin-1 character set.
\0 \x00 \u0000 The NULL character The "\0" is zero not the letter "o"
\b \x08 \u0008 The Backspace
\t \x09 \u0009 The Horizontal Tab Moves the screen cursor right, to the next tab stop.
\n \x0A \u000A Newline Line Feed
\v \x0B \u000B Vertical Tab
\f \x0C \u000C Form Feed
\r \x0D \u000D Carriage Return Position the screen cursor to the beginning of the current line.
\" \x22 \u0022 Double Quote Inserts a double quoted character in a double quoted string.
\' \x27 \u0027 Apostrophe (single quote) Inserts a single quoted character in a single quoted string.
\\ \x5C \u005C Backslash Used to insert a backslash character in a string.

Top            

Rx4AJAX        About Us | Contact Us | Privacy Policy | 2008 This Site Built By PPThompson