JS Basic
JS Objects
JS Advanced
| JS Special Text |
|
In JavaScript you can add special characters to a text string by using the backslash sign. Insert Special CharactersThe backslash (\) is used to insert apostrophes, new lines, quotes, and other special characters into a text string. Look at the following JavaScript code:
In JavaScript, a string is started and stopped with either single or double quotes. This means that the string above will be chopped to: We are the so-called To solve this problem, you must place a backslash (\) before each double quote in "Viking". This turns each double quote into a string literal:
JavaScript will now output the proper text string: We are the so-called "Vikings" from the north. Here is another example:
The example above will produce the following output:
The table below lists other special characters that can be added to a text string with the backslash sign:
|
JS Special Text