You can use either double or single quotes to declare a string.
"Hello world!" // declaring with double quotes 'Hello world!' // with single quotes 'She said, "she said"' // Using double quotes within single quotes "She said, \"Hello darling\"" // Escaping quotes with a backslash
As you can see in the above example, you can use the backslash key
\" to escape the quote.
document.write("\tHello\nWorld!"); // Hello // World!
var greeting = "Hello" + "world!";
When adding numbers and strings together, you will get a string back, with the two values concatenated.
var cost = '8' + 9; // cost = '89';
The String object comes with a number of member attributes.
var sample = "Hello there." sample.length; // 12 characters sample.substring(0,5); // "Hello" sample.toUpperCase(); // "HELLO THERE."
To get input from your user, use the
prompt() method. This will display a dialog box to the user, displaying the string passed in as an parameter to
Relieve your stress, back, neck and sciatic pain through 1,782 acupuncture points for immediate neck pain relief. Made for lower, upper and mid chronic back pain treatment, and improves circulation, sleep, digestion and quality of life.$$ Check price
Want your web site to display more quickly? This book presents 14 specific rules that will cut 25% to 50% off response time when users request a page. Author Steve Souders, in his job as Chief Performance Yahoo!, collected these best practices while optimizing some of the most-visited pages on the Web.$ Check price