There are 2 methods I discovered for defining a global object using IIFE:
(function () {
var func = function () { };
window.func = func;
}());
compared to:
(function (myFunc) {
window.func = myFunc();
}(function () {
var func = function () { };
return func;
}));
I have observed that many popular JavaScript plugins prefer the second approach, such as jQuery:
https://i.stack.imgur.com/nG5p7.png
What could be the reason for this trend?