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

How to stop execution with javascript

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

Share

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

This article introduces the relevant knowledge of "how to stop execution with javascript". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

The method to stop the execution of javascript: 1, open the corresponding js code file; 2, terminate the function operation through the return method, such as "function testA () {alert ('a'); return;alert ('b');}".

This article operating environment: windows7 system, javascript1.8.5 version, DELL G3 computer

How does javascript stop execution?

Javascript terminates the function to perform the operation

1. If you terminate a function, you can use return. The example is as follows:

Function testA () {alert ('a'); alert ('b'); alert ('c');}

TestA (); the execution of the program will pop up in turn: 'axiomagery', baccalaureate, etc., etc.

Function testA () {

Alert ('a')

Return

Alert ('b')

Alert ('c')

}

TestA (); the program execution will be terminated by popping up'a'.

2. Call another function in the function. When the called function terminates, the function you want to call also terminates. The example is as follows:

Function testC () {alert ('c'); return; alert ('cc');} function testD () {testC (); alert (' d');}

TestD (); We see that testC is called in testD, and testD is terminated through return in testC. Instead, return only terminates testC, and the program execution pops up "centering, writing and writing" in turn.

Function testC () {

Alert ('c')

Return false

Alert ('cc')

}

Function testD () {

If (! testC ()) return

Alert ('d')

}

TestD (); two functions have been modified, and the return value of testC is judged in the false,testD returned in testC, so that the testD can be terminated when the testC is terminated, and the program execution will be terminated by popping up'c'.

This is the end of "how to stop execution with javascript". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

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