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)