I'd like to create an anonymous function and then invoke it immediately.
1) This will bring a syntax error. Why?
function ()
{
alert("hello");
}();
2) wrap the function definition with () and it works.
(function ()
{
alert("hello");
})();
3) or, assign the anonymous function to a variable. It works.
var dummy = function()
{
alert("hello");
}();
Why the first way doesn't work?