1个回答
展开全部
// 1 for循环
for (i=1;i<=100;i++){ alert (i)}
//2 while循环
var i=1
while (i<=100){
alert(i);
i++;
}
//3 do while 循环
var i = 1;
do{
alert(i
i++;
}while(i <= 100);
//for in 和 forEach 用于数组的循环遍历
//4 for in
var arr1=[1,2,3,4,5,6,...99,100] ;
for (i in arr1){
alert (i);
}
//5 foreach
var arr1=[1,2,3,4,5,6,...99,100] ;
arr1.forEach(function(i){ alert(i)});
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询