Q1:while和do-while中的例子去掉“i++”邏輯上也是可行的捂贿,為何調(diào)試面板刷新時間大大延長蔫磨,什么原因造成了內(nèi)存的巨大損耗己肮?衫哥?
1茎刚、條件語句
①if(條件){語句}
②if(條件){語句}else if(條件){語句}else{語句}
③switch(表達式){
case 值1:語句
break;
case 值2:語句
break撤逢;
default:語句
}
2膛锭、循環(huán)語句
①while
var i = 1;
while(i <= 10){
document.write(i);
i++;
}```
②do-while
var i = 11;
do{
document.write(i);
i++;
}while(i <= 10)//11```
③for
for(初始化;循環(huán)條件;更新表達式){語句}
for(var i=0;i<=10;i++){
document.write(i);
}```
注意:break vs. continue
![break跳出循環(huán);
continue跳出本次循環(huán)](http://upload-images.jianshu.io/upload_images/316258-6f893f3d25e10c2b.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
④for-in
for(屬性名in對象){語句}
![Paste_Image.png](http://upload-images.jianshu.io/upload_images/316258-dd2de7be5c42a351.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
3蚊荣、with
![Paste_Image.png](http://upload-images.jianshu.io/upload_images/316258-40ac3f0eb428473c.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
4初狰、異常捕獲
try{
document.write(notDefined);
}catch(error){
console.log(error);
alert(error);
}finally{
alert('finally');
}```