The backslash (\) is used to insert apostrophes, new lines, quotes, and other special characters into a text string.
Since the backslash is the escape character, to insert the backslash itself you need to double it (\\).
var txt="We are the so-called "Vikings" from the north." document.write(txt)
In Java Script, a string is started and stopped with either single or double quotes. This means that the string above will be chopped to.
To solve this problem, you must place a backslash (\) before each double quote in "Viking". This turns each double quote into a string literal:
var txt="We are the so-called \"Vikings\" from the north." document.write(txt)
Javas Script will now output the proper text string: We are the so-called "Vikings" from the north.
Here is another example:
document.write ("You \& me are singing!")
Keywords:JavaScript Special Characters JavaScript special text