break Statement
Terminates the current loop, or if in conjunction with a label, terminates the associated statement.
break [label];
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 causes the program flow to exit the current loop or statement. Program flow resumes with the next statement immediately following the current loop or statement.
The following example illustrates the use of the labeled break statement.
function nameInDoubleArray(name, doubleArray) {
var i, j, inArray;
inArray = false;
mainloop:
for(i=0; i<doubleArray.length; i++)
for(j=0; j<doubleArray[i].length; j++)
if(doubleArray[i][j] == name) {
inArray = true;
break mainloop;
}
return inArray;
}
Show: