JavaScript Tutorial/Statement/Label

Материал из Web эксперт
Перейти к: навигация, поиск


The label keyword provides an identifier that can be used with break or continue.

You can associate a block of JavaScript statements with a label.

When a label is called using break or continue, code is executed.

    <script language="JavaScript">
       var x = 2+2;
       var y = 5*5;
       document.write("The value of 2+2 is: " + x + "<br>");
          for(i=0; i<5; i++){
              document.write("Ths value of i is: " + i + "<br>");
                 break myLabelB;
          document.write("I did some more." + "<br>");
          document.write("The value of 5 x 5 is: " + y + "<br>");