Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the jump statements in javascript

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

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

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report