We are used to seeing anonymous functions like this
The code copy is as follows:
(function(){
console.log("test");
})();
I have been calling myself-executing anonymous function before.
I found that there is another name: call the function expression immediately (IIFE, Immediately-Invoked Function Expression)
Call function expression immediately
Compared to self-executing anonymous functions, the meaning of calling function expressions immediately is clearer.
There are some examples of the self-executing function:
The code copy is as follows:
function foo() { foo(); }
as well as
The code copy is as follows:
var foo = function() { arguments.callee(); };
More importantly, something like the one below may be self-executing anonymous functions
The code copy is as follows:
var foo = function() { foo(); };