> > Yes, as others mentioned, ( function() { /*stuff*/ } )();
> > will do the trick too, and is slightly more efficient.
> is there somethign special about ( ... )(); ? I mean, how
> does this come from another example?
There's nothing special about it. Any time you have a reference to a
function, you can call that function by using () after the reference. So:
function foo() {}
foo(); // calls foo
var moo = foo;
moo(); // calls foo
var noo = (foo);
noo(); // calls foo
(foo)(); // calls foo
(moo)(); // calls foo
( true ? moo : noo )(); // calls foo
Now, for some odd syntactic reason, you can't say:
function() {}(); // error!
But remember that foo() and (foo)() are the same thing. So you can throw
some parens around the function:
( function() {} )(); // calls the function
-Mike
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/