JS中如何跳出forEach循环
方法一:改用普通for循环,这样就可以使用break,continue
1 | let arr = [1, 2, 3, 4, 5]; |
方法二:利用try…catch在特定时机抛出异常达到跳出循环的效果
1 | let arr = [1, 2, 3, 4, 5], |
Invitation
aqing
962555446
created:15/04/2021
Welcome to Candyhome
Use this card to join the candyhome and participate in a pleasant discussion together .
Welcome to aqing's candyhome,wish you a nice day .
评论