Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Declare multiple module.exports in Node.js

module.exports = {
    method: function () {},
    otherMethod: function () {},
};

or just:
module.exports = {
    fn_name1,
    fn_name2
};

Or just:
exports.method = function() {};
exports.otherMethod = function() {};

Then in the calling script:

const myModule = require('./myModule.js');
const method = myModule.method;
const otherMethod = myModule.otherMethod;
// OR:
const {method, otherMethod} = require('./myModule.js');
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #Declare #multiple
ADD COMMENT
Topic
Name
5+1 =