HI WELCOME TO SIRIS

JavaScript continue Statement

JavaScript continue statement used inside the loops, continue statement skip the current iteration and execute to the next iterations of the loop.
General Syntax
continue [ label ];
Arguments
  1. continueRequired, continue keyword skip the current iteration of the loop.
  2. labelOptional, Control transfer to specified labelled name.
Syntax
while () {
    continue;                   // skip the current iteration
}
for (;;){
    while () {
        continue;               // skip the current iteration
    }
}
Nested loop inside loop skip the current loop and control transfer to specified labelled block.
outer: {
    inner: {
        for(;;){
            while (){                                     
                continue inner;     // skip the current iteration and control transfer to inner { .. }
            }
        }                                       
    }                               // end inner
}                                   // end outer
Example (while loop) In this example we used continue, it would skip current iteration and go to the next iteration of for loop.
<script>
    var i = 0;
    while(i < 10){
        i++;
        if (i == 5){
            document.writeln("skipped, i = 5");
            continue;
        }
        document.writeln(i);
    }
</script>
Example (do..while loop)
<script>
    var i = 0;
    do {
        i++;
        if (i == 5){
            document.writeln("skipped, i = 5");
            continue;
        }
        document.writeln(i);
    } while(i < 10)
</script>
Example (for loop)
<script>
    for(var i = 0; i <= 10; i++){
        if (i == 5){
            document.writeln("skipped, i = 5");
            continue;
        }
        document.writeln(i);
    }
</script>

Example (continue with labelled block) Following example continue with labelled to skip the for loop and execution control would go to the inner label to execute the next iteration of inner loop.
<script>
for(var i = 1; i < 5; i++){
    inner:
    for (var j = 0; j < 5; j++){
        if (j == 2){
            document.writeln("skipped");
            continue inner;
        }
        document.writeln("i : " + i + ", j :" + j);
    }
    document.writeln();
}
</script>

Example Result