Answer the question
In order to leave comments, you need to log in
Module.exports how to access a property inside a module?
A small application is made like this.
1. main.js in which it is connected
2. In add.jsvar main = require('./add.js')
module.exports = {
prop1: function () { .......}
prop2: function () { .......}
prop3: function () { .......}
}
Answer the question
In order to leave comments, you need to log in
const myObj = {
prop1: function () { .......}
prop2: function () { .......}
prop3: function () { myObj.prop1() }
}
module.exports = myObj
Define a module property as a variable inside the module -- it will be possible to access it from anywhere in the module.
Associate a property with a variable.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question