break和continue区别

1、break 语句可用于跳到循环外

var str=["wxx","is","a","little","boy"],word="";
    for(var i=0;i<str.length;i++){
        if(i==3){
            break;
        }
        word=word+str[i]+" ";
    }
    console.log(word); //wxx is a

2、continue 跳出该步,继续下一个循环

for(var i=0;i<str.length;i++){
        if(i==3){
            continue;
        }
        word=word+str[i]+" ";
    }
    console.log(word); //wxx is a boy 
原文地址:https://www.cnblogs.com/xsffliu/p/7815063.html