Adscend

Click Here



Click Here

Monday

Continue Statement

Continue Statement

Continue statement is used to stop or terminate one iteration of the loop . It is used in "for”, “while”, or “do-while" loop. Continue statement unlike break statement does not completely terminate from the loop. It stops processing for only one iteration and brings the control back to the beginning of the loop.

Example

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

Output

The number i = 0
The number i = 1
The number i = 3
The number i = 4
The number i = 5

When variable ‘i’ is exactly 5, we don’t want to execute the code, after that we want to execute the code.
Here we see that “i=2” is terminated or skipped.



No comments:

Post a Comment