I can't seem to find a reference that describes the following syntax:
func() ();
This invocation of func is at the end of a constructor. Other invocations within the constructor are 'normal'.
func() returns a function, which is then invoked by the second set of ().
function func () {
return function () {
alert("ok!");
}
}
func()(); // ok!
To avoid any confusion: We know that functions get invoked like this:
functionName ();
So anything before the () is the function name,
In the case of func() () put in mind that the func() is replacing the functionName, so this is also a function call, but even func() itself is a function, so we conclude that this is a function withing a function.
And for a more appropriate definition: func() () is a function that has another function as its return value, and by doing this we are calling that returned function to be executed.
funcreturns a function when ran. So, you're runningfunc(), then running the function it returns.