1.循环数组
--------从0开始----------
var index = -1;
var arr = [8,99,44,22,7];
while(++index < arr.length){
console.log(arr[index])
}
---------从后开始---------
var length = arr.length;
while(length--){
console.log(arr[length])
}
--------------------
2.跳出循环
var iNum = 0;
var inum = 0;
outermost:
for (var i = 0; i < 4; i++) {
for (var j = 0; j < 4; j++) {
if (i == 2 && j == 2) {
break outermost;
}
iNum++;
}
inum++;
}
console.log(iNum,inum); //10 2
//---------------------------------------------
var Num = 0;
var num = 0;
outer:
for (var i = 0; i < 4; i++) {
for (var j = 0; j < 4; j++) {
if (i == 2 && j == 2) {
continue outer;
}
Num++;
}
num++;
}
console.log(Num,num); //14 3