The short: Define and immediately execute an anonymous function.

The long:

  function blah() { ... }  // define a named function

  blah();  // execute a named function


  function() { ... }  // define a function without a name (anonymous)

  // can't execute the function because it doesn't have a name


A function is just another object in JavaScript. Functions have a
special "()" method / "operator" (to use a C++ term).

  var temp = function() { ... };  // define and assign a function to a variable

  temp();  // execute the function assigned to "temp"

The final ingredient: the extra ( ... ) around the function definition
isneeded because of a language syntax "quirk".

  (function(){.....})();  // define and execute an anonymous function

Does that cover it?

Karl Rudd

On Wed, Jun 25, 2008 at 9:20 AM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> i was looking for an explanation for some of the syntax that jquery
> uses but i couldn't find it anywhere (or it seems to be). Anyways the
> syntax that i was looking for is as follows:
>
> (function(){.....})();
>
> I am assuming  that it is a javascript syntax but i don't know what it
> is called. Also If someone could explain to me what the syntax is
> actually doing it will be helpful.
>
> Thanks
>

Reply via email to