JavaScript Continue Loop Example

JavaScript continue statement used inside the loops, continue statement skip the current iteration and execute to the next iterations of the loop.

Example

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>JavaScript continue with while loop</title>
</head>
<body>
<pre>  <!-- Use pre element for work document.writeln() method -->
<script>
    var i = 0;
    while(i < 10){
        i++;
        if (i == 5){
            document.writeln("skipped, i = 5");
            continue;
        }
        document.writeln(i);
    }
</script>
</pre>
</body>
</html>

Run it...   »

Example Result