for ([initialization]; [condition]; [final-expression]) {
statement
}
An expression (including assignment expressions) or variable declaration. Typically used to initialize a counter variable. This expression may optionally declare new variables with the var
keyword. These variables are not local to the loop, i.e. they are in the same scope the for
loop is in. The result of this expression is discarded.
An expression to be evaluated before each loop iteration. If this expression evaluates to true, statement
is executed. This conditional test is optional. If omitted, the condition always evaluates to true. If the expression evaluates to false, execution skips to the first expression following the for
construct.
An expression to be evaluated at the end of each loop iteration. This occurs before the next evaluation of condition
. Generally used to update or increment the counter variable.
A statement that is executed as long as the condition evaluates to true. To execute multiple statements within the loop, use a block statement ({ ... }) to group those statements. To execute no statement within the loop, use an empty statement (;).