Download (direct link):
alert("Sorry, you entered your e-mail address incorrectly.”)//string literal x = 1.31415 * someVariable // floating-point literal if (theAnswer == true) // boolean literal
document.write("The total number of users is " + 1234)//integer literal
numberSold * salesPrice
"Thanks for visiting my site, ” + document.myForm.yourName.value
These three examples are each slightly different, but they all have one thing in common: They can all be evaluated to something. The first example evaluates to the current date; the second, to a number; the third, to a string. (A string is a group of characters that you manipulate as a single block.)
var todays_date = new Date();
calculateTotal(numberSold * salesPrice);
alert("Thanks for visiting my site, " + document.myForm.yourName.value);
In the first statement shown here, the current date is assigned to a variable called todays_date. In the second statement, the number produced by multiplying the numberSold and salesPrice variables is passed to the calculateTotal() function. And in the third example statement, the
"Thanks for visiting my site " string appears in a dialog box.
The broWser-detection script
Back in the old days, before the Web came along, developers knew exactly what hardware and software their audience would use to run their applications before they wrote a lick of code. (In other words, these developers knew their applications’ target platforms in advance.) Using this information, developers could implement their applications with confidence, secure in the knowledge that their application code would behave in the field just as it did in their testing labs.
60 Part I: Building Killer Web Pages for Fun and Profit
Can't we all just get along? The ECMA standard