Saturday 10 June 2017

Does module.exports in node js create a shallow copy or deep copy of the exported objects or functions?

For example,

If I have 2 modules try1.js and try2.js

try1.js
   module.exports.msg = "hello world";

try2.js
   try1 = require('./try1');
   try1.msg = "changed message";

Does the change in the contents of msg made in try2.js affect try value of msg in try1.js?



via Ullas Kashyap

No comments:

Post a Comment