This doesn't do too much to demystify anything, imo.
> Now how that works... I have no idea, but I do believe that it's more
aesthetic and so that's how I write my code. I won't argue if you feel
differently.
It works because (foo)() is identical to foo().
> The only reason that that even works at all is because there's magic
going on behind the scenes that hoists the anonymous function up to the top
(just like with variables) and then calls that function reference.
What am I reading? Function expression are not hoisted.
Also setTimeout() takes optional parameters to pass to the callback:
setTimeout(function(a) { console.log(a) }, 0, 'hello')
hello
Also there's Function.prototype.bind()
On Tue, Mar 19, 2013 at 7:48 PM, Jake Verbaten <[email protected]> wrote:
> Is there any good reason to ever use IIFE given that commonJS wraps my
> file in a closure.
>
> Can't every use-case for IIFE be replaced with write more smaller modules.
> At least I havn't used them in months.
>
>
> On Tue, Mar 19, 2013 at 11:44 AM, AJ ONeal <[email protected]> wrote:
>
>> Yeah, it's a good read.
>>
>> I wouldn't say the one precludes the other. We're both explaining a
>> thing, but in the context of different other things (my focus is on the
>> safety benefits).
>>
>> AJ ONeal
>>
>> On Tue, Mar 19, 2013 at 12:16 PM, Rick Waldron <[email protected]>wrote:
>>
>>> See also
>>>
>>> http://benalman.com/news/2010/11/immediately-invoked-function-expression/
>>>
>>> Not trying to rain on any parades, but Ben coined the term and his
>>> article is comprehensive
>>>
>>> Rick
>>>
>>>
>>>
>>>
>>> On Tue, Mar 19, 2013 at 2:07 PM, AJ ONeal <[email protected]> wrote:
>>>
>>>> Article + Screencast
>>>>
>>>>
>>>> http://blog.coolaj86.com/articles/how-and-why-auto-executing-function.html
>>>>
>>>> AJ ONeal
>>>>
>>>>
>> --
>> --
>> Job Board: http://jobs.nodejs.org/
>> Posting guidelines:
>> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
>> You received this message because you are subscribed to the Google
>> Groups "nodejs" group.
>> To post to this group, send email to [email protected]
>> To unsubscribe from this group, send email to
>> [email protected]
>> For more options, visit this group at
>> http://groups.google.com/group/nodejs?hl=en?hl=en
>>
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "nodejs" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>
> --
> --
> Job Board: http://jobs.nodejs.org/
> Posting guidelines:
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en
>
> ---
> You received this message because you are subscribed to the Google Groups
> "nodejs" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>
--
--
Job Board: http://jobs.nodejs.org/
Posting guidelines:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en
---
You received this message because you are subscribed to the Google Groups
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.