Get the App
SLTechnology News&Howtos  ›  Development  › 

What are the jump statements in javascript

Shulou Source: shulou.com Published: 2022-06-03 05:08:39 09月18日 Update

This article mainly explains "what jump sentences are there in javascript". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what jump sentences are there in javascript"?

Jump statements in javascript are: 1, break statement, syntax "break;"; 2, continue statement, can only be used in the loop body of loop statement, syntax "continue;"; 3, return statement, syntax "return [expression]".

The operating environment of this tutorial: windows7 system, javascript1.8.5 version, Dell G3 computer.

Jump statements can jump out of the branch, loop, or statement returned from a function call.

There are three kinds of jump statements in JavaScript: break statement, continue statement and return statement.

The break statement is used to exit the loop or switch statement. The syntax format is as follows.

Break

[example 1] in the following example, set the loop expression of the while statement to always true (while can convert the value 1 to true). Then set an if statement in the while loop structure to determine that when the variable I is greater than 50, the while loop body will jump out.

Var iTuno while (1) {if (I > 50) break; iTunes; [xss_clean] (I);}

[example 2] Jump statements can also be used in conjunction with tags to jump to a specified line, rather than just jumping out of the loop body. In the following nested for loop, define a tag x in the outer for statement, and then in the inner for statement, use the if statement to set: jump out of the outer for statement when an is greater than 5, and the result is as follows:

X:for (axi1tera

Tags: Statement loop loop body function tag syntax enough example expression learning content label similarity branch variable outer layer that is form idea situation Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei Microsoft NVidia vpn Xiaomi