In Node.JS, module.exports is a special object that is included in every JavaScript file present in the Node.JS file default. Here module is a variable that represents the current module, and export is the object that will be exposed as the module.

Here we export a string from testYourModule.js file

Example

                                        

// testYourModule.js
module.exports = "Best Interview Questions provides an example of module.exports"

// index.js
const params = require('./testYourModule.js')
console.log(params )

Suggest An Answer

No suggestions Available!