Using Continue Break in Javascript Loop

Usually a loop will be executed until the corresponding condition return false. But some times we need to control the loop statements in between Loop.To do that Javascript facilitate us. Such as for certain time we need to skip some iteration and want to start from next iteration then we can use “Continue” statement. And if we need to exit from loop at a certain time we can use “Break” statement.

Using Continue:

<script type="text/javascript">
    document.write("***** Start For loop *****</br>");
    for(i = 0; i < 5; i++)
        document.write("Iteration Number = " + i+"</br>");
    document.write("***** End For loop *****");


Look at the output. The loop skip the execution while i=2 but again start from next. This is the main factor of using Continue statement within loop. You can use this statement in every type of loops. If you still can not understand fell free to ask through comment.

Using Break:
To learn break statement please read: For Loop or While Loop or Do While Loop

Download Code Example

Leave a Reply

Your email address will not be published. Required fields are marked *

AlphaOmega Captcha Classica  –  Enter Security Code