by usablebytes · 12y ago · 0 comments
(function() {
//code here
})();
This won't affect the return type of the statement; which in case of using ! will return boolean 'true' unless the function returns a truthy value. Plus using ! for this purpose, looks totally messy. (function($,window) {
//code here
})(jQuery,window); (function(window, $, otherGlobal) {
$ = window.jQuery;
otherGlobal = window.otherGlobal;
//code here
})(window); (function(){/* stuff */}())
(function(){/* other stuff */}())
Is interpreted as: (function(){/* stuff */)())(function(){/* other stuff */}())
To correct this, you also need a semicolon. ;(function() {
//code here
})();
Alternatively, if you can stomach it (I can't), you can use the !.