> From: Leandro Vieira Pinho > > Since jQuery 1.1.4 the code library begins with that: > > (function(){ > ... > })(); > > I would like to kwon, what´s the name of that sintax. > > I have found some information in Plugins/Authoring in Custom > Alias sections. But, I would like to read more about it. But > what´s the name?
There isn't really a name for that entire thing. It's an anonymous function that is defined and called immediately. The purpose of it is to provide a local scope for variables and functions. Let's break it down: function(){/*code*/} is an anonymous function. You call a function by putting () after it, of course. But this is a syntax error for obscure reasons: function(){/*code*/}(); However, throw some parentheses around the anonymous function: (function(){/*code*/}) and now you have something that you can call by adding parens afterward: (function(){/*code*/})(); By creating and calling a function, any "var" statements or function definitions inside that function are local to the function. -Mike