Learn Scripting Languages from the Master!
A statement is an instruction that instructs a computer (JavaScript interpreter) to carry a specific action. For example,
document.write ("This is a JavaScript statement.");
instructs the computer to print "This is a JavaScript statement." In JavaScript, statements are terminated with a semicolon or return statement. Because statements in JavaScript are ended with a semicolon, multiple statements can be grouped on one line, for example:
var x; x = 60; document.write (x);
In JavaScript, statements can also be terminated with a line break character, for example,
var xx = 60document.write (x)The above three lines are treated as three separate statements as:
var x;x = 60;document.write (x);To avoid ambiguity and any unintended results, use a semicolon to mark end of a statement instead of relying on an implicit semicolon insertion (or a linebreak character).