Do...while Statement
The Do...while statement is a looping statement that runs first and then judges. In other words, the loop body is run at least once, regardless of whether the condition is satisfied.
var box = 1; If it is 1, execute five times, if it is 10, perform 1 times
do {
alert (box);
box++;
} while (box <= 5); Run first, then judge
for...in Statement
The for...in statement is a precise iterative statement that can be used to enumerate the properties of an object.
var box = {//Create an Object
' Name ': ' Li Tinghui ',//key value pair, left is the property name, the right is the value
' Age ': 28,
' Height ': 178
};
For (var p in box) {//Enumerate all properties of an object
Alert (p);
}
Break and Continue Statement
The break and continue statements are used to precisely control the execution of code in a loop. Where the break statement exits the loop immediately, forcing the statement following the loop body to continue executing. While the continue statement exits the current loop, the loop continues behind.
for (var box = 1; box <=; box++) {
if (box = = 5) break; If box is 5, exit the loop
document.write (box);
document.write (' <br/> ');
}
for (var box = 1; box <=; box++) {
if (box = = 5) continue; If box is 5, exit the current loop
document.write (box);
document.write (' <br/> ');
}
with Statement
The function of the WITH statement is to set the scope of the code to a specific object.
var box = {//Create an Object
' Name ': ' Li Tinghui ',//key-value pair
' Age ': 28,
' Height ': 178
};
var n = box.name; Assigning values from objects to variables
var a = Box.age;
var h = box.height;
The above three-segment assignment can be rewritten as:
With (box) {//Omitted box object name
var n = name;
var a = age;
var h = height;
}
JS Flow control Statement