Chapter 6. Statements
6.1. Expression Statements
s = "Hello " + name; i *= 3;
alert("Welcome, " + name); window.close( );
These client-side function calls are expressions, but they also affect the web browser, so they are statements, too. If a function does not have any side effects, there is no sense in calling it, unless it is part of an assignment statement. For example, you wouldn't just compute a cosine and discard the result:
Instead, you'd compute the value and assign it to a variable for future use:
cx = Math.cos(x);
Again, please note that each line of code in each of these examples is terminated with a semicolon.
Copyright © 2003 O'Reilly & Associates. All rights reserved.