Wednesday, January 8, 2014

Immediate invocation in Javascript

is handled, for example,  thusly

(function ($) {
})(jQuery);


the () is needed because otherwise JS thinks function is a decleration, the JQuery is passed in
 so the code can now reference JQuery as a "$" without having to traverse the scope chain looking for the variable 

No comments:

Post a Comment