I am having a hard time figuring out how this following module scope works in node.js.
main.js
module.exports = App = {
add: function(a, b) {
return a + b;
}
}
var getNumber = require('./module');
var result = App.add(100, getNumber());
module.js
var number = 200;
module.exports = function () {
console.log(App); // App is visible here - how come?
return number;
};
I wonder why App is visible in the module, since it is not required in. If I no longer export App, it is not visible.