The difference between break and continue in JavaScript

break statement and continue statement


##break statement

  • Description: break statement, used to unconditionally end various loops (exit the loop) and switch.

  • Note: Generally, you need to add a conditional judgment before the break statement. In other words: when the condition is established, the loop exits.


##continue statement

    Description: End this cycle and start the next cycle. The code after continue is no longer executed.
  • Note: Generally, you need to add a conditional judgment before the continue statement.
  •     php.cn  
    
Note: Observe the results first, then comment out break, use continue instead, and observe the results again. It can be seen that when the conditions are met, break will jump out of the loop directly. When the loop operation is performed again, and continue is used instead, the condition is met, the current loop is jumped out, and the next loop is entered.

Continuing Learning
||
php.cn
submit Reset Code
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!