Home >Web Front-end >JS Tutorial >How to use Break and Continue in JavaScript programs

How to use Break and Continue in JavaScript programs

高洛峰
高洛峰Original
2016-11-28 13:54:511236browse

This is about js tutorial-JavaScript Break and Continue usage. There are two statements that can be used in loops: break and continue.

JavaScript break and continue statements

There are two special statements that can be used inside loops: break and continue. The

Break

break command can terminate the execution of the loop and then continue executing the code after the loop (if there is code after the loop).

Example:





Result:
The number is 0
The number is 1
The number is 2
Continue

The continue command will terminate the current loop and continue from the next value.

Example:





Results:
The number is 0
The number is 1
The number is 2
The number is 4
The number is 5
The number is 6
The number is 7
The number is 8
The number is 9
The number is 10

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn