I have linked to/closed for the related questions as to "what it does", as to "how" this works:
expression(...)
always treats the result of expression as a function-object and attempts to invoke it. (If the result is not a function-object there is an error.)
function (...) {...}
-- in an expression context -- evaluates to the anonymous function-object. It never invokes said function.
$
is just a "normal identifier" or, an expression in this case. (It is likely that $ === jQuery
in this example.)
Thus, the above is semantically equivalent of (ignoring property pollution):
func = $;
anon_func = function () {...};
func(anon_func);
Exactly what func
does with anon_func
is up to func
. In this case, because func
and $
and jQuery
evaluate to the same function-object, the behavior is defined by jQuery(callback).
Happy coding.