On 26/09/2013, at 08:52, Ashish Negi wrote:
> I find that when i execute only node then it gets the 'require' and 'module'.
> And when i run it with a test_file.js like "node test_file.js" and print the
> global in it, the global does not have the 'require'.
>
> But then how does the very next line that uses 'require' does not throw the
> error ?
Because `require` is a parameter. Your test_file.js is called wrapped in a
function:
```
(function (require, path, etc) {
/* the text of "test_file.js" goes here */
})(require, path, etc)
```
That's why it's in scope, but not because it's a global, it isn't.
--
( Jorge )();
--
--
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.