JS Statements and Arrays

Source: Internet
Author: User
Tags case statement

Statement:

Order : Executes from top to bottom, ending with a semicolon.

branching : Let the program execute different code depending on the condition.

If statement: Determines whether the given condition is satisfied, according to the result of the decision (true or false) decide to perform one of the two operations given.

Basic syntax:

1. if (condition) {code}.

2. if (condition) {Code}else{code}.

3. if (condition) {code}else if (condition) {Code}else{code}.

Switch...case statement:: First set the 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.

Basic syntax:

Switch (variable)

{

Case x:

x= "Output Amount";

Break

Case y:

y= "Output Amount";

Break

}

Break: Jumps out of the loop, enclosing the curly braces.

Continue: Jump out of this cycle.

Cycle:

Looping through a function (executing a piece of code)

Four elements: cyclic initial value; cyclic condition; state change; Loop body.

For loop:

While loop:

Not to be continued ....

JS Statements and Arrays

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.