JavaScript anonymous function self-invocation

Source: Internet
Author: User

//self-invocation of anonymous functions/*var f1 = function () {Console.log (' I am an anonymous function! ');}*///F1 ();//above is the definition of an anonymous function, and then called, in fact, the variable name above, and then use () to invoke//This will be an error, because the function body of the curly braces are separated, can not explain the use of small expansion number to adjust the priority/*function F2 () {Console.log (' is I am an anonymous function and is self-invoking! ‘);} ();*/(functionf3 (name) {Console.log (' Yes I am an anonymous function, and it is self-invocation! ' +name);}) (' Sentiger '); //the benefit of using anonymous function self-invocation: Prevent the function from being polluted, the file is large, it is likely to have duplicate names, and may affect each other when introducing a third-party plug-in. Like some jquery frameworks are self-invoking using anonymous functions to prevent contamination

JavaScript anonymous function self-invocation

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.