JQ报错:Uncaught SyntaxError: Illegal continue statement: no surrounding iteration statement报错

今天在写轮播图中,在停止定时器之后想要重新开启定时器,但是不知道为什么脑子抽了竟然想通过continue跳出定时器的本次运行继续下一次运行(当然是不可取的,但是还是试了试2333),然后就报错了。Uncaught SyntaxError: Illegal continue statement: no surrounding iteration statement

 

在jquery的for中以及定时器中写continue会报错(其他的还没有试过,但是看到网上说foreach也会报错)

查找之后的解决办法:

使用 return; 或者 return true; 来代替 continue 语句;
使用 return false; 来代替 break语句;

 

原博传送门:https://blog.csdn.net/likeflower950/article/details/75807430

 

posted @ 2019-08-02 21:47  一粒草莓  阅读(1998)  评论(0)    收藏  举报