(function ($) { 'use strict' ... })(jQuery);
This will make $ available only in the area of ββthe anonymous self-starting function, this means that $ will not pollute the global area, and it will ensure that $ jQuery . If other frameworks set their own $ (for example, a prototype), inside the closure of the $ function there would be jQuery , because jQuery is a passed parameter that will be called and accessible inside the function like $ . Local scope variables in JavaScript take precedence over the parent scope .
(function () { 'use strict' ... })();
This is an anonymous self-consistency function, acting as a closure, usually to preserve local variables rather than leak them into the global scope.
source share