Re: [nodejs] Why the use of (function(){})();

99 views
Skip to first unread message

Naouak

unread,
Sep 28, 2012, 8:29:13 AM9/28/12
to nod...@googlegroups.com
To sandbox the content of the function.
In javascript the scope is defined by functions.
So by doing that, if your code is well enough written (meaning no "var" forgotten), your code will be correctly sandboxed.

Naouak, Grade 2 de Kobal.
Site web: http://www.naouak.net


On Fri, Sep 28, 2012 at 2:20 PM, Sadjow Leão <sad...@gmail.com> wrote:
Why the use of (function(){

})();

in the files ?

--
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 nod...@googlegroups.com
To unsubscribe from this group, send email to
nodejs+un...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Ryan Schmidt

unread,
Sep 28, 2012, 9:47:00 AM9/28/12
to nod...@googlegroups.com

On Sep 28, 2012, at 07:20, Sadjow Leão <sad...@gmail.com> wrote:

> Why the use of (function(){
>
> })();
>
> in the files ?

http://benalman.com/news/2010/11/immediately-invoked-function-expression/



Mark Hahn

unread,
Sep 28, 2012, 2:14:22 PM9/28/12
to nod...@googlegroups.com
There is a command-line option to turn that off.  I think it is "-b" for "bare"

Reply all
Reply to author
Forward
0 new messages