i came across this piece of script in the source code of a chrome extension. it declares a function:
jQuery(function($){
$('#actionCopy').click(function(e){
Action.copy();
});
});
what is that jQuery word used at the beginning of the function? and what does the dollar sign that is used as the function argument do? ( function($) )
jQuery(/**args**/)just like you'd expect for any other function. The argument passed to thejQuery()function just happens to be another function. Functions are objects and can be passed around just like any other data.$is a parameter to the function argument. When invoked it is passed a value. That value is a function. The function argument passed to$just so happens to be the samejQueryfunction, so now you have two different references to the same function.jQuery === $; // true(function($){ //code })(jQuery);