The break and continue of JavaScript

Source: Internet
Author: User
Tags terminates

Break statement
Use the break statement to terminate the loop.
Continue statements
use the Continue statement to terminate the current loop, and then proceed from the next value.

JavaScript Break and Continue statements

There are two special types of statements that can be used inside loops: Break and continue.

Break

The break command terminates the run of the loop and then resumes execution of the code after the loop (if there is code after the loop).

Instance:
{break} document.write ("The number is" + i) document.write ("<br/>")}</script></body>
Results:
The number is 0The number was 1The number is 2

Continue

The continue command terminates the current loop and then continues to run from the next value.

Instance:
{continue} document.write ("The number is" + i) document.write ("<br/>")}</script></body>
Results:
The number is 0The number are 1The number is 2The number are 4The number is 5The number are 6The number is 7The number is 8Th E number is 9The number is 10

The break and continue of JavaScript

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.