break statement syntax : Break : Statement JAVASCRIPT TUTORIALS


JAVASCRIPT TUTORIALS » Statement » Break »

 

break statement syntax










The keyword break exits out of loop structures and switch statement.

When a label is used, JavaScript completely breaks out of the area designated by label.

To label a statement, place the label name followed by a colon (:).

Labels are useful when working with nested loops.












<html>
    <SCRIPT LANGUAGE='JavaScript'>
    <!--
    forLoop1:
    for (var counter1 = 1; counter1 <= 5; counter1++)
    {
      for (var counter2 = 1; counter2 <= 5; counter2++)
      {
        document.write("Counter1=",counter1);
        document.write(" Counter2=",counter2,"<BR>");
        if (counter2 == 3)
          break;
        if (counter1 == 3)
          break forLoop1;
      }
    }
    document.write("All done!");
    //-->
    </SCRIPT>
</html>







HTML code for linking to this page:

Follow Navioo On Twitter

JAVASCRIPT TUTORIALS

 Navioo Statement
» Break