What are the two types of jump statements in javascript?

青灯夜游
Release: 2022-01-20 19:20:18
Original
2534 people have browsed it

Two jump statements in JavaScript: 1. The break statement is used to exit a loop or exit a switch statement to allow the program to continue executing the code after the loop. The syntax is "break;"; 2. The continue statement is used To exit this loop and start the next loop, the syntax is "continue;".

What are the two types of jump statements in javascript?

The operating environment of this tutorial: windows7 system, javascript version 1.8.5, Dell G3 computer.

There are two main types of jump statements supported by javaScript:

  • break statement

  • continue Statement

The main difference between the break statement and the continue statement is: break is to completely end the loop, continue is to end the current loop

1. break statement:

The break statement is used to exit a loop or exit a switch statement, allowing the program to continue executing the subsequent code. The break statement is usually used in while, do...while, switch or for statements

Grammar:

break;
Copy after login

Description:

The break statement is usually used in while, do...while.switch or for

Example:

    break语句  
Copy after login

The preview effect in the browser is as follows:

What are the two types of jump statements in javascript?

2, continue statement

continue statement and break statement similar. The difference is that the continue statement is used to exit this loop and start the next loop. The break statement exits all loops!
Grammar:

continue;
Copy after login

Description:

Like the break statement, the continue statement can only be used in loops such as white, do...while, for and switch. Example of

in the statement:

     
Copy after login

will be previewed in the browser as follows:

What are the two types of jump statements in javascript?

[Related recommendations:javascript Study tutorial

The above is the detailed content of What are the two types of jump statements in javascript?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!