Possible Duplicate:
What is the purpose of wrapping whole Javascript files in anonymous functions like “(function(){ … })()”?
I have seen this kind of code specially when dealing with jQuery plugins. Can someone please explain me what this does?
(function(){
//Stuff goes here....
}());
They are defining a function in Javascript between the braces (the stuff goes here part would be the code to be executed) and then immediately executing it using the open and closed parens. This doesn’t have to do with JQuery, it is just an anonymous function in javascript. the
function(){}returns a function object which is then executed by the open and closed parens.