I find this easier to explain in code:
var a = { b: {} }; // a = modules, a.b = modules.exports
var b = a.b; // b = exports
b.hello = 'world'; // set a key on "exports", works.
b = { goodbye_cruel: 'world' }; // set "exports" to a whole new object,
doesn't
console.log(a); // outputs: { b: { hello: 'world' } }
a.b = { goodbye_cruel: 'world' }; // set "module.exports" to a whole new
object works.
console.log(a); // outputs: { b: { goodbye_cruel: 'world' } }
On Fri, Oct 18, 2013 at 8:20 AM, spion <[email protected]> wrote:
>
>
> On Friday, October 18, 2013 3:57:34 AM UTC+2, yougen zhuang wrote:
>>
>>
>> exports = Rect;
>>
>>>
>>>
> Here is a helpful diagram that I often use to explain this:
>
> http://i.imgur.com/bNG7JfZ.png
>
> --
> --
> 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.