JavaScript
Escape Characters
JavaScript provides special characters that allow you to include
characters in strings that you cannot normally include - either because it will cause an
error or because there is no single character for it. Each of these characters,
known as escape characters, begins with a backslash. The backslash is the escape
character that tells the JavaScript interpreter that the next character is
special.
|
Escape Sequence |
Character |
|---|---|
|
\b |
Backspace |
|
\f |
Form feed |
|
\n |
Line feed (newline) |
|
\r |
Carriage return |
|
\t |
Horizontal tab |
|
\' |
Single quotation mark |
|
\" |
Double quotation mark |
|
\\ |
Backslash |
| \uHHHH | Unicode encoded character (where HHHH is character code) |
| \### | Latin encoded character (where ### is character code) |
Notice that because the backslash itself is used as the escape character, you cannot directly type one in your script! If you want to use a backslash, you must type two of them together (\\).
document.write('The path to the file is C:\\program files\\mystuff\\readme.txt.');
document.write('He thought for one moment and then said, "I really didn/'t suspect the problem to be with the hard drive."');
Forgetting to use escape characters properly will result in errors in your JavaScripts. Take care that you get them right!
- Spam Buster!
- Add a snow effect
- Using JavaScript with Shockwave Flash Player
- Using Strict Equality
- Escape Characters
- Regular Expressions - JScript
- JavaScript Reserved Words Table
Interested in programming, but don't know where to start? Beginning Programming will get you going! >> Go!
|
|
Out Now!