Explanation of the usage of loop control statements in JavaScript _ basic knowledge-js tutorial

Source: Internet
Author: User
This article describes the usage of loop control statements in JavaScript, including the use of break statements and continue statements, you can refer to JavaScript to provide full control to process loops and switch statements. There may be a situation where you need to exit a loop but not reach its bottom. Alternatively, when you skip a part of the block and start the next iteration directly.

To handle these situations, JavaScript provides break and continue statements. These statements are used to immediately exit any loop or start the next iteration of the loop.
Break statement:

Break statement. This is a simple introduction using the switch statement. It is used to exit the loop in advance and break the closed curly braces.
Example:

This example shows how to use the break statement with the while loop. Note that the loop breaks the front and bottom of the document. write (...) statement from x to 5 at the beginning, and uses the right braces:

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.