An anonymous function is a function without a name. For example, function () {alert (& amp; #39; afunction & amp; #39;) ;}but the above Code reports an error. Firebug prompt: functionstatementrequiresaname, that is, the function must have a name. The strange thing is, like...
An anonymous function is a function without a name. For example:
Function (){
Alert ('a function ');
}
However, the above Code will report an error. Firebug prompt: function statement requires a name, that is, the function must have a name.
The strange thing is that if I use a pair of () to package the function with no name, no error will be reported. For example:
(Function (){
Alert ('a function ');
})
(Note the () of the function package ()!). Although no error will be reported in this way, who knows if this function is declared successful? Is it because there is no declaration? Let's test: Let the function execute it once:
(Function (){
Alert ('a function ');
}())
As you can see, the function is executed, indicating that the function exists.
Similarly, if you remove the wrapped function () at this time, the previous error will still be reported and the function cannot be executed...
Function (){
Alert ('a function ');
}()
From 10-year Lamp