Loop structure
Loop: Perform the operation repeatedly
* For Loop
for (var i=1; i<=50; i++) {
Console.log ("+i+", "I Love You");
}
Expression 1 var i = 1
Expression 2 i<=50 loop condition
Expression 3 i++
Three expressions separated by semicolons
Loop body------curly Braces statements (statements that need to be executed repeatedly)
Execution Flow: S1 First Execute expression 1
S2 executes expression 2, expression 2 is true, and continues S3
If the expression 2 is false, the loop ends here.
S3 Execution Loop Body
After S4 S3 is complete, execute expression 3 to continue back to S2
Analysis I=1---->1<=50------> Output 1th time I love you---->i=2----->2<=50----> Output 2nd time I love you--->i=3----->3<=50 -----> ....
Example
Loop nesting
* Break and Continue
Break is used in a switch or any loop, indicating that the structure is out of the corresponding
Continue is used only for loops, ending this cycle to continue the next cycle
* While loop
* Do-while Cycle
1!+2!+3!+4!+ ... 10!
js-5-Cycle