aquaballoon

Node.js - exports (import)

Jul 7th, 2014
286
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.24 KB | None | 0 0
  1. // module.js
  2. exports.y = 2;
  3.  
  4. var x = 1;
  5. exports.foo = function(callbackfn) {
  6.     return callbackfn(x * 2);
  7. };
  8.  
  9.  
  10. // app.js
  11. var module = require('./module.js');
  12.  
  13. module.foo(function(x) {
  14.     console.log(x);
  15. });
  16.  
  17. console.log(module.y);
Advertisement
Add Comment
Please, Sign In to add comment