Which keyword is used to stop the loop prematurely?

  • break
  • continue
  • exit
  • return
The keyword used to stop a loop prematurely in JavaScript is "break." When "break" is encountered within a loop, it immediately exits the loop, even if the loop condition is still true or there are more iterations remaining. This is useful for early termination of a loop based on a specific condition. "continue" skips the current iteration and moves to the next one, while "exit" and "return" have different purposes and are not used for loop control.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *