12.6 Iteration statements

2010-05-23

IterationStatement :
do Statement while ( Expression ) ;
while ( Expression ) Statement
for ( ExpressionNoIn(opt) ; Expression(1)(opt) ; Expression(2)(opt) ) Statement
for ( var VariableDeclarationListNoIn ; Expression(1)(opt) ; Expression(2)(opt) ) Statement
for ( LeftHandSideExpression in Expression ) Statement
for ( var VariableDeclarationNoIn in Expression ) Statement

This is the crux of all the NoIn productions.

Note that while the third iteration statement all has optional productions, the semi-colons are required or a SyntaxError is thrown. This is because the Automatic Semi-colon Insertion algorithm never inserts one in a for statement. Therefor something like "for () break;" would not be expanded to "for (;;) break;" and that's obviously bad.