Skip to main content

NodeJS: Managing files communication

1. module.exports
It is an object that the current module returns when it is required in another program or module

2. require(' ')

Example:
#myModule.js
var a = 'I am student';
module.exports = a;

#callmyModule.js
var result = require('./myModule');
console.log('Result is:', result);
//Output: Result is: I am student;

Comments