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 

 

posted @ 2017-11-10 15:51  心随风飞lss  阅读(128)  评论(0编辑  收藏  举报