N writing methods of anonymous functions in javascript

Source: Internet
Author: User

The private attribute is available in java, and the powerful function js cannot be implemented as a dwarf, anonymous function, and wide variety of functions.
If an anonymous function has no actual name or pointer, how can this problem be solved?
In fact, you can understand the meaning of parentheses. Parentheses return values, that is, the return values of functions or expressions in parentheses. Therefore, the return values of functions in parentheses are equal to the return values of parentheses, which is not hard to understand (function (){})() you can execute a function without a name...
The writing of anonymous functions is very divergent ~

// The most common usage:

(Function (){

Alert ('water ');

})();

// Of course, parameters can also be included:

(Function (o ){

Alert (o );

}) ('Water ');

// Do you want to use the chained call of anonymous functions? Simple:

(Function (o ){

Alert (o );

Return arguments. callee;

}) ('Water') ('low ');

// All common anonymous functions are available. See the following:

~ (Function (){

Alert ('water ');

})();

// The writing method is cool ~

Void function (){

Alert ('water ');

}();

// It is said that the efficiency is the highest ~

+ Function (){

Alert ('water ');

}();

-Function (){

Alert ('water ');

}();

~ Function (){

Alert ('water ');

}();

! Function (){

Alert ('water ');

}();

(Function (){

Alert ('water ');

}());

// A bit of forcible execution taste ~

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.