JavaScript While LOOP tutorial

Source: Internet
Author: User

The loop in JavaScript is used to specify the number of times the same code is executed (or when the specified condition is true ).
JavaScript Switch Declaration
If you want to execute one of several code blocks, you can use the switch statement:
Syntax:
Copy codeThe Code is as follows:
Switch (n)
{
Case 1:
Execution Code Block 1
Break
Case 2:
Execution Code Block 2
Break
Default:
If n is neither 1 nor 2, execute this code
}

Working principle: the (n) behind the switch can be an expression or (and usually) a variable. Then, the value in the expression is compared with the number in case. If it matches a case, the subsequent code is executed. Break is used to prevent the code from being automatically executed to the next line.
Instance:

[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]

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.