關于代碼中的數(shù)值判斷if和if...else
? function at(){
? ? ? ? ?index++;
? ? ? ? ?if(index>=list.length){
? ? ? ? ? ? ?index=0;
? ? ? ? ?}
? ? ? ? ?ch(index);?
? ? ? ??
? ? ?}
為什么ch(index);不能換成else{ch(index);}
? function at(){
? ? ? ? ?index++;
? ? ? ? ?if(index>=list.length){
? ? ? ? ? ? ?index=0;
? ? ? ? ?}
? ? ? ? ?ch(index);?
? ? ? ??
? ? ?}
為什么ch(index);不能換成else{ch(index);}
2016-12-13
舉報
2017-01-19
function ?autoPlay(){
? ?index++;
? ?for (var i = 0; i < list.length; i++) {
? ? ? ?if (index >= list.length) {
? ? ? ? ? ?index =0;
? ? ? ?}
? ? ? ?else {
? ? ? ? ? ?changePic(index);
? ? ? ?}
? ?}
}
能啊,代碼寫全就是這樣的啊。老師是簡寫的寫法啊,if后面的else不是必要的。
2016-12-15
else是不成立的時候執(zhí)行!