Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 7th, 2012  |  syntax: None  |  size: 0.25 KB  |  hits: 12  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Understanding Node.js modules: multiple requires return the same object?
  2. // app.js
  3.  
  4. var a = require('./a');
  5. a.b = 2;
  6. console.log(a.b); //2
  7.  
  8. var b = require('./b');
  9. console.log(b.b); //2
  10.  
  11. // a.js
  12.  
  13. exports.a = 1;
  14.  
  15. // b.js
  16.  
  17. module.exports = require('./a');