ES6 - Label with continue


Advertisements

Example

outerloop: // This is the label name
for (var i = 0; i < 3; i++) {
   console.log("Outerloop: " + i);
   for (var j = 0; j < 5; j++) {
      if (j == 3) {
      continue outerloop;
      }
      console.log("Innerloop: " + j );
   }
}

The following output is displayed on successful execution of the above code.

Outerloop: 0
Innerloop: 0
Innerloop: 1
Innerloop: 2
Outerloop: 1
Innerloop: 0
Innerloop: 1
Innerloop: 2
Outerloop: 2
Innerloop: 0
Innerloop: 1
Innerloop: 2
Advertisements