In NodeJS, if we define functions using this keyword, it gets exposed.
for example:
// module.js
this.func1 = function () {
console.log('func1');
}
Then, If you require('module') you can access func1.
I want to know that how it is different than module.exports?
Thanks
Simple test: create new file and do:
console.log( this );
console.log( module.exports );
this.test = 1;
console.log( this );
console.log( module.exports );
which clearly shows that this is a reference to module.exports, i.e. there is no difference.