Using Break Statement in JavaScript

Using the break statement:

Break statement allows you to break or exit a loop. When used inside a loop, the break statement stops executing the loop and causes the loop to be immediately exited. If the loop has statements after the break statement, the statements does not execute.

Demo:

  1. Let’s create a document called breakStatement.html.

    notepad

  2. Write the following code:

    code

  3. Execute the script by opening the file in the web browser. If you are using Internet Explore click on “Allow Blocked Content” to allow the script to execute and if you are using Mozilla Firefox then click on allow “ActiveX Controls”.

    Execute the script
    Thanks for reading the blog.
Ebook Download
View all
Learn
View all