function(){} ();
By itself (see the comment on the point) will not be valid, since
function() {}
- function declaration. To call it immediately, you need to make the JavaScript engine treat the function as an expression. Usually people do it like from
(function(){}) ();
from
!function(){}();
just being a shortened version of the same.
source share