January 2001
Beginner
312 pages
6h 4m
English
In the interactive story example, you saw a JavaScript escape character in action—the \ ", which in a string represents a double quote. Escape characters are used in strings to do the following:
Prevent certain characters from causing errors
Add formatting (such as carriage returns) to strings
Table 5.1 lists the available escape characters.
| Sequence | Name |
|---|---|
| \b | Backspace |
| \t | Horizontal tab |
| \f | Form feed |
| \n | New line (line feed) |
| \r | Carriage return |
| \" | Double quote |
| \' | Single quote |
| \\ | Backslash |
These can be placed anywhere in the string and need no whitespace before or after them.
Here are some examples of escape characters in action:
Carriage return
<script language="JavaScript"> <!-- Cloaking device on! alert("A ...Read now
Unlock full access