do {
console.log(i);
} while(i < 10);
for...in
statements iterates over all the enumerable properties of an object.
var fruit = ['apple', 'banana', 'cherry']
for(var i in fruit) {
console.log(i); // '0', '1', '2'
console.log(fruit[i]); // 'apple', 'banana', 'cherry'
}
for(var i; i < 10; i++) {
console.log(i);
}
for...of
loops through iterable objects, similar to python for..in
loops.
var fruit = ['apple', 'banana', 'cherry']
for(var f of fruit) {
console.log(f); // 'apple', 'banana', 'cherry'
}
break_both_loops: for(var i = 0; i < 10; i++) {
for(int j = 0; j < 10; j++) {
if(i + j >) {
break break_both_loops;
}
}
}
while(i < 10) {
console.log(i);
}