| break The break statement is used to 'break' out of a looped circumstance, such as an if else loop or a switch condition. Using a JavaScript label, which is stated before a given chunk of code, the browser will execute this following chunk of code when it comes upon the break. The label must be stated in the form 'labelName:'. When the break occurs, it is a good programming convention to state the break as 'break labelName;', even if there is only one label and one break in that particular piece of code. Notice that the label, when stated before the chunk of code, has a colon following it. The label, when stated with the break and referring to the label, has a semi-colon following it. syntax: break label: EXAMPLE loopLabel: for (arguments) { for (arguments) { if (arguments) { break loopLabel; } } } The example shows that the label name is 'loopLabel'. Several for statements and one if statement later, the 'break loopLabel;' is given, which tells the script to jump to the loopLabel: and begin again. |