If statement
...
if (expression) {when and when, execute statement 1
EXECUTE Statement 1
}
If there is only one statement, you can do without {}, such as: if () immediately after the execution of the statement
...
if (expression) {If an expression is true, then execute statement 1
Statement 1
}else{Otherwise, execute statement 2
Statement 2
}
...
if (expression 1) {EXECUTE Statement 1 as set
Statement 1
}else if (expression 2) {No re-judgment expression 2
Statement 2
}else{are not established.
Statement 3
}
This is the same as we draw the flowchart, judging leap year, two conditions reached
Switch statement
...
Switch (parameter) {
Case 1:
Statement 1;
Break
Case 2:
Statement 2;
Break
Case 3:
Statement 3;
Break
Case 4:
Statement 4;
Break
Case 5:
Statement 5;
Break
Default
Statement 6
None of the preceding conditions have been reached, the last statement
}
Strict equality operator, does not trigger type conversion
Cycle
To do certain things repeatedly
1,while Cycle
1,while (expression 1) {//If the condition is true
Perform
Expression 2
}
Expression 3
Judge first, then execute. Prior loop
Description: First judge the expression 1, set up the execution Expression 2, and then continue to judge the expression 1, if not the execution of an expression 3
2,do while loop
2,do{
Expression 1
}while (expression 2);
Expression 3
First execution once, then judge, the posterior cycle
Description: First executes expression 1, in the judgment Expression 2, if established, continues to execute expression 1, does not establish the execution expression 3;
3,for Cycle
Expression 1: Determines the initial value of the loop and executes only once at the beginning of the loop;
Expression 2: Check the loop conditions, as long as the real follow-up operations;
Expression 3: Complete the follow-up, then go back to the previous step and check the loop condition again
3,for (expression 1, expression 2, expression 3) {
Expression 4
}
Executes expression 1 First, executes expression 2, executes expression 4, executes expression 3, and then executes expression 2
Continue jump out of this cycle
Break jumps out of the current loop only for loop use
JavaScript----Loops