JavaScript: Break And Continue

แชร์
ฝัง
  • เผยแพร่เมื่อ 11 พ.ค. 2024
  • #javascript
    In JavaScript, the break statement is used to exit a loop prematurely. When the break statement is encountered inside a loop (such as a for or while loop), it terminates the loop immediately, regardless of the loop's condition. This allows you to exit the loop early based on a certain condition, without completing all iterations of the loop.
    In JavaScript, the continue statement is used to skip the current iteration of a loop and proceed to the next iteration. When the continue statement is encountered inside a loop (such as a for or while loop), it skips the remaining code inside the loop for the current iteration and moves on to the next iteration of the loop. This allows you to skip certain iterations based on a specific condition, without terminating the entire loop.
  • วิทยาศาสตร์และเทคโนโลยี

ความคิดเห็น • 2