Home  >  Article  >  Web Front-end  >  Tutorial on the difference between JavaScript Break and Continue_Basic knowledge

Tutorial on the difference between JavaScript Break and Continue_Basic knowledge

WBOY
WBOYOriginal
2016-05-16 19:15:391119browse

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

Break
The 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:


[Ctrl A Select all Note: If you need to introduce external Js, you need to refresh to execute
]

Result:
The number is 0
The number is 1
The number is 2Continue
The continue command will terminate the current loop and continue from the next value.

Example:

[Ctrl A Select all Note:
If you need to introduce external Js, you need to refresh to execute
]

Result:
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