views:

61

answers:

3
+7  A: 

This defines an anonymous function with one argument, called $, then invokes the function passing jQuery as the argument.

Ned Batchelder
Aaah... ok, makes sense. Thanks
Parched Squid
+1  A: 

It's called the self executing anonymous function. No different than any other function call except the function is a literal ( doesnt have a name ), is wrapped in parens to make it a valid expression and then invoked.

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

is the same as that piece of code, it creates a private namespace in which the window.jQuery object is passed and referenced within the function body as $ to prevent namespace collisions.

meder
+1  A: 

This is an example of the JavaScript module pattern.

Scott Bale