Introduction to immediate execution function expressions in JavaScript, javascript expressions
We are used to seeing such an anonymous function.
Copy codeThe Code is as follows:
(Function (){
Console. log ("test ");
})();
Previously, self-executing anonymous function was called)
It turns out that there is another way to call the Function Expression Immediately (IIFE, Immediately-Invoked Function Expression)
Call function expression now
Compared with self-executed anonymous functions, the meaning of immediate call of function expressions is clearer.
Examples of Self-executed functions are as follows:
Copy codeThe Code is as follows:
Function foo () {foo ();}
And
Copy codeThe Code is as follows:
Var foo = function () {arguments. callee ();};
More importantly, the following may be self-executed anonymous functions.
Copy codeThe Code is as follows:
Var foo = function () {foo ();};