JS Continue Statement



Skipping Part of Loop : Continue Statement in JavaScript

Continue Statement in JavaScript

  • It is used for Skipping part of Loop.
  • Continue causes the remaining code inside a loop block to be skipped and causes execution to jump to the top of the loop block
  • continue statement will takes control back to the position where we checks condition.

Continue Statement : Syntax

loop
{
  continue;
  //code
}

Different Variations of Continue Statement :

Loop
Use of Continue !!
for
while
do-while

Live Example : Using For Loop

<html>
<body>

<script type="text/javascript">
var i=0;
for (i=0;i<=5;i++)
{
if (i==3)
  {
  continue;
  }
document.write("The number is " + i);
document.write("<br />");
}
</script>

</body>
</html>

Output :

The number is 0
The number is 1
The number is 2
The number is 4
The number is 5