1:switch
Key fields: Switch (n), case, break, default
Switch (n): n is an expression or a variable that is used to match the various cases below, such as: At this point the day output is a number 5. Matched to case 5, the corresponding value is output.
Default: Code that executes when the case item is not matched to
How it works: first set an 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.
Format of Usage:
Two:
break: Used to jump out of a loop. After jumping out of the loop and executing the code after the loop (the code that jumps out of the entire loop), return immediately ends the entire code (not just jumping out of the loop body but ending the entire code process). )。
The Bewak directly ends the entire loop.
continue: Used to skip an iteration in the loop. The iteration of the interrupt loop, if the specified condition occurs. The next iteration in the loop is then resumed. For example, when executing to i=3, the code after i=3 is immediately terminated, and the execution i=4 is entered.
JavaScript switch continue break execution statement