I found this snippet when I looked at jQuery plugins and wondered what it actually does
Skeleton jQuery plugin:
(function($) { ... })(jQuery);
And most recently in nettuts :
var STICKIES = (function () { ... }());
This creates an anonymous function and calls it directly: this is equivalent
var fun = function(){}; fun();
jquery , '$'. sekeleton , "$" ( , "$" ), "jQuery", $ = jQuery, .
:
function($) { ... }
. : (jQuery); jQuery ( $ ).
(jQuery);
jQuery
$
nettuts .
The first function means that $ is being overwritten by jQuery, which is useful if you gave a different "$" value in the script.