for循环,forEach循环。

  try{
            [1,2,3].forEach((item)=>{
                console.log(item)
                if(item == 1){
                    throw new Error()
                }
            })  
        }catch(e){
            console.log(111)
        }
注意原始的for循环里面不能写return,如果想要跳出for循环就要break
咱们所用的foreach中的循环,如果数据庞大,想让他停下来的办法。
posted @ 2020-03-05 14:33  国服第一李师师  阅读(150)  评论(0编辑  收藏  举报