let arr=[1,2,3,4,5]
try{
arr.forEach((ress)=>{
if(ress==2){
throw('满足条件,forEach循环终止')
}
})
}catch(e){
console.log(e) //满足条件,forEach循环终止
}
js终止forEach循环
最新推荐文章于 2024-07-05 16:41:23 发布
let arr=[1,2,3,4,5]
try{
arr.forEach((ress)=>{
if(ress==2){
throw('满足条件,forEach循环终止')
}
})
}catch(e){
console.log(e) //满足条件,forEach循环终止
}