sorry guys, you need the parens. try it:

function(){ var foo = false; }();

will produce a syntax error.

On Tue, Aug 3, 2010 at 7:37 AM, Ryan Florence <[email protected]> wrote:

> I heard somebody (Paul lrish I think?) say at a conference that at google
> they use !function to indicate it's self-invoking.
>
> I think (function ... is more common though.
>
> On Aug 3, 2010, at 6:15 AM, Fábio M. Costa wrote:
>
> jiggliemon,
>
> no you dont need the extra parentheses, you could do:
>
> function(){
> ...
> }();
>
> but with the extra parentheses its more clear that you are creating a self
> executing function. Its kind of a convention, kind of...
>
> --
> Fábio Miranda Costa
>
>
>
> On Tue, Aug 3, 2010 at 8:11 AM, Sid-ahmed D 
> <[email protected]>wrote:
>
>> Thank you for all reply :P
>>
>> On 3 août, 07:15, jiggliemon <[email protected]> wrote:
>> > FMI, must one include the first set of parentheses to create a
>> > closure?
>> > An old book I was reading said that it's just extra sugar.
>> >
>> > function(){
>> >    ...stuff...
>> >
>> > }();
>> >
>> > Is just the same. They say.
>> >
>> > -chase
>> >
>> > On Aug 2, 6:09 pm, Fábio M. Costa <[email protected]> wrote:
>> >
>> > > It creates a closure, so the variables you create inside it wont be
>> global
>> > > variables. It's basically to avoid creating global variables cause
>> maybe you
>> > > can overwrite something you had before and stuff like that. It's
>> safer.
>> >
>> > > --
>> > > Fábio Miranda Costa
>> >
>> > > On Mon, Aug 2, 2010 at 11:00 AM, Sid-ahmed D <
>> [email protected]>wrote:
>> >
>> > > > Perfect, it's working now.
>> > > > Thank you.
>> >
>> > > > just to understand.
>> > > > What does the parentheses in your example ? reduced to a function?
>> > > > ( fu....)();
>> >
>> > > > On 2 août, 15:48, Fábio M. Costa <[email protected]> wrote:
>> > > > > Yes you can, look:
>> >
>> > > > >http://jsfiddle.net/6UqAP/10/
>> >
>> > > > > @Dimitar Christoff:
>> >
>> > > > > You can create a request at each click but its not the correct
>> way. This
>> > > > way
>> > > > > you are being inefficient by creating a request at each click.
>> >
>> > > > > You dont need to create a request object at each click, just send
>> a
>> > > > request.
>> > > > > You can change the properties of the request passing an options
>> object to
>> > > > > the send call, shown in my example.
>> >
>> > > > > If you dont wanna ignore the other clicks you can use the other
>> link
>> > > > > options:
>> >
>> > > > >    - cancel: if you try to send another request when a request is
>> being
>> > > > sent
>> > > > >    the current one is aborted and the new one will be sent;
>> > > > >    - chain: if you try to send another request whan a request is
>> being
>> > > > sent
>> > > > >    it will be chained, and will be called when the last chained
>> request
>> > > > is
>> > > > >    called.
>> >
>> > > > >http://mootools.net/docs/core/Request/Request
>> >
>> > > > > chain example:
>> >
>> > > > >http://jsfiddle.net/6UqAP/15/
>> >
>> > > > > click 3 times in a row, it will call the first, when it finishes
>> another
>> > > > > will be called and then another.
>> >
>> > > > > --
>> > > > > Fábio Miranda Costa
>> >
>> > > > > On Mon, Aug 2, 2010 at 10:09 AM, Sid-ahmed D <
>> > > > [email protected]>wrote:
>> >
>> > > > > > I can not put a variable "url" in this configuration.
>> > > > > > Could you please help me ?
>> >
>> > > > > >http://jsfiddle.net/KzMDG/1/
>> >
>> > > > > > Thank
>> >
>> > > > > > On 2 août, 11:17, Dimitar Christoff <[email protected]>
>> wrote:
>> > > > > > > > You should never create the request object inside the click
>> event.
>> >
>> > > > > > > and why not if you don't plan on recycling it?
>> >
>> > > > > > > Best regards,
>> > > > > > > --
>> > > > > > > Dimitar Christoff <[email protected]>
>> > > > > > > blog:http://fragged.org/twitter:http://twitter.com/D_mitar
>>
>
>
>

Reply via email to