I’m a little confused with what’s going on with a common pattern I keep seeing. It usually looks like this.
(function( w ){
w.functionName = function(){
// Function stuff, blah blah blah
};
}( this ));
Another common one I see looks like:
(function( $ ){
$.fn.functionName = function(){
// Function stuff, blah blah blah
};
}( jQuery ));
I’m some what familiar with anonymous functions, though I’m curious, what is w, and what is it being used for?
What is the reason for this/jquery at the end of the anonymous function.
Thanks for all the feedback on this! I appreciated all the responses.
wis just being the formal name of parameter of a function(normal thing, and it this example, actual parameter isthisorjQuery). I don’t know why jQuery in this given example is doing thing, probably it is considered as kind of nice initialization.Example: