Three major process control (sequential process, branch control, loop control)

Source: Internet
Author: User

control statements for 1.Javascript

① Sequential Control

② Branch Control

2.1 Single Branch

If (conditional expression)

{ EXECUTE statement }

2.2 Dual Branch

If (conditional expression){

}else{

}

2.3 Multi-branch

If (conditional expression){

Execution

}else if()

{

Execution

}else if ..... ()// can have multiple else if

{

Execution

}

else{

can not

}

Emphasize one point: once you have found an entry that satisfies the condition, when the execution is complete, the entire multi-branch is ended directly.

Switch ( conditional expression ) {

Case constant 1:

execute the statement;

Break

.......

Default:

Execution

}

Case:

var a =80;switch (a) {case 890:window.alert ("890");//function is to jump out of the entire switchcase  90:window.alert ("" "); Default:window.alert ("No matching value");

For this case:

(1) JS switch statement data type can be any type supported by JS (except for arrays and objects)

(2) the data type following the case can be arbitrary (except for arrays and objects)

(3) Break action is to jump out of the entire switch

(4) If there is no match, execute default

varFlag =1;Switch(flag) {default: Window.alert ("default") Case 'a': Window.alert ("today is Monday"); Case 'b': Window.alert ("today is Tuesday");}//Three of cases are performed

varFlag =1.1;Switch(flag) {default: Window.alert ("default"); Case 'a': Window.alert ("today is Monday"); Case 'b': Window.alert ("today is Tuesday"); Case 1.1: Window.alert ("1.1");}//will only appear 1.1//default does not prompt

Three major process control (sequential process, branch control, loop control)

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.