美文网首页
forEach跳出循环

forEach跳出循环

作者: Aklan | 来源:发表于2017-11-15 17:33 被阅读0次

for循环可以用break或return跳出循环,forEach不能
jquery的$.each也不能用break,可以用return

try{
    arr.forEach((item,index)=>{
        if(){
                 //
             foreach.break = new Error("StopIteration")
            }
     })
 }catch(e){
    if(e.message === "foreach is not defined") {
           //console.log("...")
     }else throw e
}

相关文章

网友评论

      本文标题:forEach跳出循环

      本文链接:https://www.haomeiwen.com/subject/bydtvxtx.html