I think I understand the module pattern, but why do some examples pass JQuery in as a parameter like this:
Namespace.AppName = (function ($) {
// Code Here
})(jQuery);
If I don’t pass in JQuery I can still use the Jquery library just fine by making $() calls inside the module. So why do some people do this?
The idea here is that you pass
jQueryas$to the inside function, making sure that the$IS jQuery. This is commonly used to protect code that uses$especially when using jQuery along with other libraries that use$like mootools.example, if you had this code in the
<head>