A string literal is zero or more characters enclosed in matching single or double quotes. Each character may be represented by an escape sequence.
You can escape special characters with special escape sequences. You can also escape any character and specify it by its octal, hexadecimal or Unicode equivalent code point. Note that the octal values will be in the range 0 to 377 and the hexadecimal values will be in the range 0 to FF. The octal and hexadecimal escapes can only cover the first 256 character codes, some of which are control codes and should not be used anyway. The Unicode escape gives access to the full 65536 character codes in the Unicode set. Although you can specify octal or hexadecimal values, there is presently no standardized decimal-based escape mechanism. You'll just have to learn octal or hexadecimal, unfortunately.
Here are the valid common escape sequences:
|\'||Single Quote (Apostrophe)||'|
|\a||Audible alert (MSIE displays the letter a)||<BEL>|
|\b||Backspace (ignored silently in MSIE)||<BS>|
|\f||Form Feed (ignored silently in MSIE)||<FF>|
|\n||Line Feed (Newline - MSIE inserts a space)||<LF>|
|\r||Carriage Return (MSIE inserts a space)||<CR>|
|\t||Horizontal Tab (MSIE inserts a space)||<HT>|
|\v||Vertical tab (MSIE displays the letter v)||<VT>|
|\047||Single Quote (Apostrophe)||'|
|\x27||Single Quote (Apostrophe)||'|
|\u0027||Single Quote (Apostrophe)||'|
|\uFFFE||A special Unicode sentinel character for flagging byte reversed text||-|
|\uFFFF||A special Unicode sentinel character||-|
Here are some example string literals:
myString = "James Bond";
myString = 'Another String';
myString = 'A string with double " quotes';
myString = "He's got a single quote";
The characters in the quotes are converted to a String primitive value and will replace the expression in the context in which it has been used. This would normally be an assignment of a variable or perhaps part of a relational expression.
Put an escape round the quotes. Sometimes a backslash is appropriate and sometimes an HTML character entity depending on who you are trying to hide the quotes from.
You cannot include a line terminator within a string literal. Instead use a newline (\n) escape sequence.
Currency symbols are notoriously non-portable. Check that your target audience can display international currency symbols before using GB pounds or Euro symbols. Although these are defined in the standards, they are often missing from the installed character sets.
ECMA 262 edition 2 - section 7.7.3
ECMA 262 edition 2 - section 7.7.4
ECMA 262 edition 3 - section 7.8.4