JavaScript switch continue break execution statement

Source: Internet
Author: User

1:switch

Key fields: Switch (n), case, break, default

Switch (n): n is an expression or a variable that is used to match the various cases below, such as: At this point the day output is a number 5. Matched to case 5, the corresponding value is output.

Default: Code that executes when the case item is not matched to

How it works: first set an expression n (usually a variable). The value of the subsequent expression is compared to the value of each case in the structure. If there is a match, the code block associated with the case is executed. Use break to prevent your code from automatically running down a case.

Format of Usage:

  

Two:

   break: Used to jump out of a loop. After jumping out of the loop and executing the code after the loop (the code that jumps out of the entire loop), return immediately ends the entire code (not just jumping out of the loop body but ending the entire code process). )。

  

  

The Bewak directly ends the entire loop.

  continue: Used to skip an iteration in the loop. The iteration of the interrupt loop, if the specified condition occurs. The next iteration in the loop is then resumed. For example, when executing to i=3, the code after i=3 is immediately terminated, and the execution i=4 is entered.

  

JavaScript switch continue break execution statement

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.