11.8 break statement

2010-05-23

BreakStatement :
continue [no LineTerminator here] Identifier(opt) ;

A Program is considered to be syntactically incorrect when a break statement occurs that's not nested (somehow) within a IterationStatement or SwitchStatement. Functions act as a boundary here. It's also incorrect when the label for a break statement does not occur in the enclosing IterationStatement (again, functions act as boundaries).

Code: (Meta Ecma)
function evaluate(break ;) {
return Completion('break', undefined, undefined);
}


Code: (Meta Ecma)
function evaluate(break Identifier ;) {
return Completion('break', undefined, Identifier);
}

On the meta level, break acts like continue except continue may not occur in a switch and only continue to a label in the IterationStatement. Other mechanisms make it so break ends an iteration while continue initiates the next iteration.