Statement: Defines the main syntax for the program structure in ES. Typically use one or more keywords to accomplish a given task
Statements can be very simple or complex.
Three basic structures of the program: circular structure of sequential structure branching structure
Branch: Single-branch, double-branch, multi-branch, nested (used for judgment purposes)
Single branch:
if (conditional expression) {
if sentence;
}
Conditional expression: Returns a Boolean value that, when True, enters into {} to execute an IF clause and does not enter {} When False
Dual Branch:
if (conditional expression) {
if sentence;
}else{
else sentence;
}
If the conditional expression is met, the IF clause is executed, otherwise the ELSE clause is executed
Else cannot exist alone, dependent on if exists. If there is a conditional expression after, else there is no conditional expression, but there is an implied condition year, as opposed to if
Multi-branch:
if (conditional expression 1) {
}else if (conditional expression 2) {
}else if (conditional expression 3) {
}...
else{
}
Branch nesting:
if (conditional expression 1) {
if (conditional expression 2) {
}else{
}
}else{
if (conditional expression 2) {
}else{
}
}
In the statement, as long as there is "{}" represents the end of the current statement, so we do not need to use ";" And then the concluding sentence
Switch statement: Multi-branch
switch (expression) {
Case value1://Expression ===value1
Case Statement 1;
Break
Case value2:
Case Statement 2;
Break
...
Default
Default statement;
}
1 expression: The usual way of a variable. More than just a conditional expression
2 {}: cannot be omitted
3 Case: Indicates the occurrence of each situation. Executes the following case statement if the expression conforms to the current situation. How many instances of an expression are there,
The number of case and case statements are listed, and the value following the case is the possible value of the expression.
4 Default: The default statement is executed when the expression does not match any of the preceding lines
5 Break: You can add the break keyword after each case. Exit the switch statement if you encounter a break, and if you do not break, the program will continue to execute down until a break is encountered
6 Any expression can use the switch statement
7 switch statements can be interchanged with an if statement
The 8 switch statement uses the congruent operator when comparing values, so type conversions do not occur
Web Front end java Script Learning 2017.7.8