When I call function hi()()
with double brackets the function displays hi
output and it will also give error saying, that hi
is not functi
Putting ()
after something that evaluates to a function will call that function. So, hi()
calls the function hi
. Assuming hi
returns a function then hi()()
will call that function.
Example:
function hi(){
return function(){return "hello there";};
}
var returnedFunc = hi(); // so returnedFunc equals function(){return "hello there";};
var msg = hi()(); // so msg now has a value of "hello there"
If hi()
doesn't return a function, then hi()()
will produce an error, similar to having typed something like "not a function"();
or 1232();
.