var a = [1,2,3,4,5]
try{
a.forEach(item => {
if(item == 3) {
throw new Error("err")
}
})
} catch(e) {
if(e.message != "err") throw e
}
var a = [1,2,3,4,5]
try{
a.forEach(item => {
if(item == 3) {
throw new Error("err")
}
})
} catch(e) {
if(e.message != "err") throw e
}
本文标题:中断forEach循环
本文链接:https://www.haomeiwen.com/subject/wmesrrtx.html
网友评论