JavaScript termination function Execution action

Source: Internet
Author: User
Tags terminates

1, if you terminate a function with return, the example is as follows:
function TestA () {
Alert (' a ');
Alert (' B ');
Alert (' C ');
}
TestA (); Program execution will pop up ' a ', ' B ', ' C ' in turn.

function TestA () {
Alert (' a ');
return;
Alert (' B ');
Alert (' C ');
}
TestA (); Program execution popup ' a ' will terminate.

2, call another function in the function, the call function terminates at the same time you want to call the function terminates, the example is as follows:
function Testc () {
Alert (' C ');
Return
Alert (' cc ');
}

function TestD () {
TESTC ();
Alert (' d ');
}
TestD (); We see in the TESTD called TESTC, in Testc want to return TESTD also terminated, backfired return only terminate TESTC, program execution will pop up ' C ', ' d '.

function Testc () {
Alert (' C ');
return false;
Alert (' cc ');
}

function TestD () {
if (!TESTC ()) return;
Alert (' d ');
}
TestD (); Two functions have been modified, TESTC returned FALSE,TESTD in the return value of TESTC to make a judgment, so that the end of TESTC can also terminate the TESTD, the program execution popup ' C ' will be terminated.

JavaScript termination function Execution action

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.