Search code examples
jqueryjavascriptwindow-object

Why does jQuery send in window to itself when it can just call it from within


I tried this myself and I suppose its some sort of closure catch but I dont see the difference in this:

(function() {
 var tvLib = {}
 window.tvLib = tvLib
})();

from the jQuery way of :

(function(window, undefined) {
var jq;
window.jq = jq;
})(window);

Im confused why I need to send in window object if I can call it anyway.


Solution

  • One reason is to let minifiers rename the variable to make it more compact.