Break statement in javascript

break statement in javascript

break statement is used to terminate the loop statement.

Example

Try Yourself

Example Explanation

  • In the above loop if the break statement is not used it will display 0, 1, 2, 3.
  • In the second loop, break statement is executed. So the following loop will be terminated and the control will move to the next statement (alert("Finished")).
  • So only 0 will be displayed.