JavaScript Tutorial


Total available pages count: 33
Subject - JavaScript Frameworks

Escaping Literals

For characters not listed in the preceding table, a preceding backslash is ignored, with the exception of a quotation mark and the backslash character itself.

You can insert quotation marks inside strings by preceding them with a backslash. This is known as escaping the quotation marks.

 For example,

var quote = "Slightbook is a \"pocket friend\" ";
document.write(quote);

The result of this would be: Slightbook is a "pocket friend"

To include a literal backslash inside a string, you must escape the backslash character. For example, to assign the file path c:\temp to a string, use the following:

var home = "c:\\temp";

To include a literal backslash inside a string, you must escape the backslash character. For example, to assign the file path c:\temp to a string, use the following:

var home = "c:\\temp";


Comments