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
This book teaches HTML as if it's for anyone - hobbyists, students, and professionals - and it's full-color throughout. It utilizes information graphics and lifestyle photography to explain the topics in a simple way that is engaging. You can progress through the chapters from beginning to end or just dip into topics of particular interest at your leisure.$ Check price
Relieve spasms, tight muscles, trigger points and pressure points with the Body Back Buddy! This trigger point massage is designed to help you self-message any area of your body - especially those that are hard to reach. Keeping your muscles relaxes and out of contraction is importan in helping to reduce pain and prevent muscle injury.$ Check price