Execution of the function (Immediately-Invoked Function Expression, IIFE) immediately

Immediate execution function : a function declaration, and immediately call this anonymous function is called immediately execute the function

In two ways:

 

 

 

Except that () operator outside! , +, -, =, and so the operator can immediately perform functions

 

 Use the benefits of immediate execution function : to execute the function immediately by defining an anonymous function, create a new function scope, creating the equivalent of a "private" namespace, the namespace variables and methods, and will not damage the overall pollution Namespaces.

Global parameters can be accessed by passing

 

Guess you like

Origin www.cnblogs.com/ranxt/p/12367009.html