break Statement (JScript 5.6) 

Terminates the current loop, or if in conjunction with a label, terminates the associated statement.


break [label];

Remarks

The optional label argument specifies the label of the statement you are breaking from.

You typically use the break statement in switch statements and while, for, for...in, or do...while loops. You most commonly use the label argument in switch statements, but it can be used in any statement, whether simple or compound.

Executing the break statement exits from the current loop or statement, and begins script execution with the statement immediately following.

Example

The following example illustrates the use of the break statement.

function BreakTest(breakpoint){

   var i = 0;

   while (i < 100)

   {

   if (i == breakpoint)

      break;

      i++;

   }

   return(i);

}

Requirements

Version 1

See Also

Reference

continue Statement (JScript 5.6)
do...while Statement (JScript 5.6)
for Statement (JScript 5.6)
for...in Statement (JScript 5.6)
Labeled Statement (JScript 5.6)
while Statement (JScript 5.6)