Loop Controls in JavaScript:

In JavaScript you can handle your loops and switch statements. To handle all type of situation JavaScript provides you “break” and “continue” statements.

The Break Statement:

You already know how to use break statement in switch. Break statement is used to terminate the current loop and also terminates the associated statements.

Now in following example we use break statement in while loop

Example:

The Continue Statement:

The continue statement will terminates the execution of statements in the current iteration of a loop and start execution of the loop with the new iteration.

Example:

 

Leave a Reply

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