Why zambesiaca anonymous function to convey the global parameters?

Good afternoon.
Why JS when declaring anonymous functions sloveniaas often pass in parameters global objects:

(function (w, d, $) {
//body
}(window, document, jQuery));

They are passed by reference and are visible from the inside, so why not call them from inside? To reduce?
March 23rd 20 at 19:36
2 answers
March 23rd 20 at 19:38
Solution
To guarantee that they will not disappear and will not change, even if someone is after your jQuery script write = null.

For faster access (although this is probably irrelevant), the local variable is looked up faster than the hike up the scopes.
but if the objects are passed by reference, they will change inside, right? - Gregorio_Cronin commented on March 23rd 20 at 19:41
Will change. This protection is not from semeneya, and remove the link. Compare:

jQuery = { x: 1 };
(function() {
 setTimeout(() => console.log(jQuery.x), 0);
}());
jQuery = null;


jQuery = { x: 1 };
(function(jQuery) {
 setTimeout(() => console.log(jQuery.x), 0);
}(jQuery));
jQuery = null;
- clotilde.Tromp87 commented on March 23rd 20 at 19:44
March 23rd 20 at 19:40
Yes.

Find more questions by tags JavaScript