JavaScript Break and Continue

In JavaScript basicaly break statement is used for jumps out of a loop.

While the continue statement is used for jumps over one iteration in the loop.

Example of Break statement

You have already seen the break statement used in above paragraph. It was used to "jump out" of a switch() statement. The break statement can also be used to jump out of a loop:

<script type = "text/javascript">
for (let i = 0; i < 10; i++) {
  if (i === 3) { break; }
  text += "The number is " + i + "
"; } </script>

Example of continue statement

The continue statement breaks one iteration (in the loop), if a specified condition occurs, and continues with the next iteration in the loop.

<script type = "text/javascript">
for (let i = 0; i < 10; i++) {
  if (i === 3) { continue; }
  text += "The number is " + i + "
"; } </script>






The Best

Comment here

If you have any query, if you want to know something about any of technical course related to computer science field, if you have any suggestion about relevant to uploaded content or if you anything wrong here (any mistake in content) than please contact us. Keep in mind, comment should be according to community guidelines.