Re: [nodejs] diff between module.exports and exports

2013-10-19 Thread Ryan Schmidt
On Oct 18, 2013, at 21:59, David Cyrus wrote: > Hi, why do you need to do that? I don’t understand. > > module.exports = exports = foo I have already answered this question earlier in this thread. -- -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/w

Re: [nodejs] diff between module.exports and exports

2013-10-18 Thread Hage Yaapa
Well, that's from Node 0.4.x, it's been a long time (6 minor versions and 2 years), things have changed quite a bit. Thanks for bringing into notice. I should update that post. On Tue, Oct 15, 2013 at 5:23 PM, mks wrote: > Not that nice. Mostly wrong. > What happens is something like: > > var m

Re: [nodejs] diff between module.exports and exports

2013-10-17 Thread Ryan Schmidt
On Oct 17, 2013, at 20:51, yougen zhuang wrote: > My question is not about how to keep reference intact, but why module.exports > and exports point to different object when only assign module.exports You've already received multiple explanations in this thread about how it works. If you under

Re: [nodejs] diff between module.exports and exports

2013-10-15 Thread yougen zhuang
I still have a question, since module and module.exports both are object, modify exports will reflect in module too. But just setting exports will not work. For my example, exports = Rect, in the main.js, can't invoke any function on Rect // main.js var rect = require('Rect'); 在 2013年10月15日星期二U

Re: [nodejs] diff between module.exports and exports

2013-10-15 Thread yougen zhuang
thanks, I got it now 在 2013年10月15日星期二UTC+8下午7时53分10秒,mks写道: > > Not that nice. Mostly wrong. > What happens is something like: > > var module = { exports: {}} void function ( module, exports ){ > module.exports.name = 18 // assignment of the "name" property of the > "exports" object. > exports.a

Re: [nodejs] diff between module.exports and exports

2013-10-15 Thread mks
Not that nice. Mostly wrong. What happens is something like: var module = { exports: {}} void function ( module, exports ){ module.exports.name = 18 // assignment of the "name" property of the "exports" object. exports.answer = 42 // assignment of the "answer" property of the "exports" local va

Re: [nodejs] diff between module.exports and exports

2013-10-15 Thread Anand George
Nice write-up here... http://www.hacksparrow.com/node-js-exports-vs-module-exports.html On Tue, Oct 15, 2013 at 3:52 PM, yougen zhuang wrote: > Before assign value to exports, module.exports === exports, but after > assign value, they're not equal. In my view, they're point to the same > refer

[nodejs] diff between module.exports and exports

2013-10-15 Thread yougen zhuang
Before assign value to exports, module.exports === exports, but after assign value, they're not equal. In my view, they're point to the same reference. BTW, if I modify to module.exports.Rect = Rect, then module.exports === exports function Rect(w,h) { this.w = w; this.h = h; }; Rect