nodejs multiple module exports

Module file

file name – operator.js

const add = (a, b)=>{
return a +b ;
}
const sub = (a, b)=>{
return ab ;
}

const name =‘kanha’;

module.exports = {add, sub , name};

index file – where you are importing the modules 

filename = index.js

const op = require(‘./operator’);
console.log(op.add(2,5));

console.log(op.sub(2,5));

console.log(op.name);

Leave a Comment

Your email address will not be published. Required fields are marked *