Special characters are used to cause a string to perform some action when printed.
Syntax
The syntax for special characters is
variable = "text \specialcharacter text"
or
document.write ("text \specialcharacter text")
where variable is the name of a variable that stores the string, text is any text, and specialcharacter is:
b, f, n, r, t, or a quotation mark (?).
Description
The special characters and the role played by each are listed below in Table 1. However, be forewarned that only the \" character appears to work in Windows-based Web browsers.
Table 1: JavaScript Special Characters for String Literals.
| Character | Meaning |
| \b | Backspace |
| \f | Form feed |
| \n | New line |
| \r | Carriage return |
| \t | tab |
| \" | quotation mark |
Example
myQuote = "Stephanie said \"Hello\" as she rode by."
document.write(myQuote)When executed, the document.write statement puts this on the screen:

|
|
![]() |