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;".
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;
Description:
The break statement is usually used in while, do...while.switch or for
Example:
The preview effect in the browser is as follows:
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;
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:
will be previewed in the browser as follows:
[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!