All you need to understand is the difference between FunctionExpressions and FunctionDeclarations in Javascript.
When you surround a function with parentheses -
(function sayHello (name) {
alert("Hello there " + name + "!");
})("Mike");
- you, technically, apply a grouping operator to it. After application, the general production is no longer a FunctionDeclarataion, but a FunctionExpression. Compare -
function foo(){ }
(function foo(){ });
typeof function(){ };
new function(){ };
FunctionExpression ( FunctionDeclaration), MemberExpresson, Arguments ( "(" ")" ) . , .
, FunctionExpressions ( FunctionDeclarations, ), "sayHello" -
(function(){
alert('...');
});
, .