Javascript examples for Statement:continue
Using the continue statement with a label reference, to skip a value in a nested for loop:
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {//from ww w . ja v a 2 s.c o m var text = ""; var i, j; Loop1: // The first for loop is labeled "Loop1" for (i = 0; i < 3; i++) { text += "<br>" + "i = " + i + ", j = "; Loop2: // The second for loop is labeled "Loop2" for (j = 10; j < 15; j++) { if (j === 12) { continue Loop2; } document.getElementById("demo").innerHTML = text += j + " "; } } } </script> </body> </html>