The break Statement



Navigation Aids -- This Page           Navigation Aids -- This Topic           Navigation Aids -- This Site








Introduction And Review

The break statement instructs the interpreter to exit the loop immediately. The entire looping control structure is broken with no additional iteration. With the execution of the break statement, program flow will resume at the next sequential statement following the loop. When the optional label is included, the block structure specified by the label is terminated. The break statement can only be used inside a repetition control structures (while, do/while, for, for/in) and the switch statement.

The break statement used in the switch statement will exit the switch/case statement and continue execution at the statement following the switch statement. If the break statement were omitted from each case, the interpreter would execute each statement in all the case structures.

Both the continue and break statements allow for premature exiting from a loop. These two statements give you additional flow control within your looping process.





Statement Syntax


break labelname;



More on Syntax and Statement Behavior





ECMA-262 Section 12.8

The break statement is an ECMAScript core statement and is detailed is section 12.8 of the ECMAScript Language Specification. Here is a partial extraction of text from this section.

An ECMAScript program is considered syntactically incorrect if either of the following are true:



Top            

Rx4AJAX        About Us | Topic Index | Contact Us | Privacy Policy | 2008 This Site Built By PPThompson