break 和 continue
break:跳出此循环,并结束此循环;
continue:跳出此循环,不结束,继续下一次循环;
DEMO如下:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> </head> <body> <script> for(var i=0;i<5;i++){ if(i == 3){ break; }; console.log('第一个for循环:' + i); } for(var i=0;i<5;i++){ if(i == 3){ continue; }; console.log('第二个for循环:' + i); } </script> </body> </html>
RESULT如下:
author:Lik
Endeavoring to powerless, struggling to move yourself.
Endeavoring to powerless, struggling to move yourself.