What is the loop structure of JavaScript program?
Today, I will talk to you about what the loop structure of the JavaScript program is. Many people may not know much about it. In order to make you understand better, the editor has summarized the following content for you. I hope you can get something according to this article.
Select structure
Single branch if structure
If (condition) {Code executed after the condition is met}
If there is only one statement in the curly braces, you can omit the curly braces at this time, but it is strongly not recommended
If (conditional) console.log ('dot')
Two-branch if structure statement
If (condition) {code executed after the condition is satisfied} else {code executed after the condition is not met}
Multi-branch if structure statement
If (condition 1) {Code 1} else if (condition 2) {Code 2} .else {none of the above conditions satisfy the executed code}
Switch structure
Var today=1switch (today) {case 1: console.log ('working day') break case 2: console.log ('working day') break case 3: case 4: case 5: console.log ('working day') break Default console.log ('rest Day') break
The difference between switch and if
Switch can only wait. It's worth judging if.
There is no limit to the judgment suitable for a continuous interval.
Cyclic structure
Performing an operation repeatedly is a loop.
While// cycle 10 times var i=1while (I