I've noticed this pattern of wrapping closures in parens ()
(function () 开发者_开发百科{
var foo = 1;
return function () {return foo}
}())
It raises the question, how is this supposed to be parsed:
function () {
var foo = 1;
return function () {return foo}
}()
The parentheses around the function are necessary, because when omitted, the compiler assumes it is a Function Statement.
Function statements are not invocable.
精彩评论