At certain points in time, you want to set only certain functions / variables for explicit properties window.
(function() {
var jQuery = function(selector) { alert( selector ) }
})();
jQuery
If we change it as:
(function() {
var jQuery = function(selector) { alert( selector ) }
window.jQuery = jQuery;
})();
then we “explicitly expose” it from the private namespace.
, window. , alert, , , .
window. , alert, . , , alert, ...
(function() {
function alert() {}
alert('lol');
window.alert('lol')
})();
alert , , . window.alert, .
, window., . , , document alert , , .