The set of named statements includes var, if, switch, for, while, do, break, continue, return, try, throw, and with. Most of them work the same as in other C-like languages.
The var statement is a list of one or more variables names, separated by commas[e88] , with optional initialization expressions.
var a, b = window.document.body;
If the var statement appears[e89] outside of any function, it adds members to the Global Object. If it appears inside of a function, it defines local variables of the function.
In if statements, while statements, do statements, and logical operators, JavaScript treats false, null, undefined, "" (the empty string), and the number 0 as false. All other values are treated[e90] as true.
The case labels in a switch statement can be expressions. They don't have to be constants. They can be strings.
There are two forms of the for statement. The first is the common[e91] (init; test; inc) form. The second is an object iterator.
for (name in object) {
if (object.hasOwnProperty(name)) {
value = object[name];
}
}
The block is executed[e92] for each name in the object. The order in which the names are produced is not guaranteed.
Statements can have a label prefix, which is an identifier followed with a colon.
The with statement should not be used.