module.exports
is the object that's returned as the result of a require
call. You can use it to export a single value or a list of values. It helps in achieving modular programming.
// Define a value.
const myValue = 'Hello, World!';
// Export the value.
module.exports = myValue;
Then, in another file, you can use require to access that value:
// Load the value.
const myValue = require('./path/to/my/module');
console.log(myValue); // Outputs: "Hello, World!"