Thứ Năm, 4 tháng 2, 2016

Label and Continue in javascript

     Any identifier can use as label name. We can use a label to identify a loop and use the continue statements to continue the execution.

Example
 label1:
for (a = 0; a < 3; a++) {      //The first for statement is labeled "label1"
   loop2:
   for (b = 0; b < 3; b++) {   //The second for statement is labeled "label2"
      if (a === 1 && b === 1) {
         continue label1;
      }
      alert("a = " + a + ", b = " + b);
   }
}


 


Example Program:- (Editor)


Editor is Loading...

Advertisement

0 nhận xét:

Đăng nhận xét