JS Anonymous call to implement code _JAVASCRIPT skills

Source: Internet
Author: User
Tags anonymous
OK, let's see how anonymous functions are invoked.
1, after the execution of the return value of the function call
JS Code
Copy Code code as follows:

Mode 1, call the function, get the return value. The force operator makes the function call execute
(function (x,y) {
alert (x+y);
return x+y;
} (3,4));


JS Code
Mode two, call the function, get the return value. Force the function to perform a direct amount of execution and return a reference, and then invoke the execution
Copy Code code as follows:

(function (x,y) {
alert (x+y);
return x+y;
}) (3,4);



2. Ignore return value after execution
JS Code
Copy Code code as follows:

Mode three, call function, ignore return value
void function (x) {
x = x-1;
alert (x);
} (9);

Mode three, call function, ignore return value
Copy Code code as follows:

void function (x) {
x = x-1;
alert (x);
} (9);

Well, finally, look at the wrong way of calling.
JS Code
The wrong way to call
Copy Code code as follows:

function (x,y) {
alert (x+y);
return x+y;
} (3,4);

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.