I am trying export all the overloaded functions of a js file. So that I can reuse them in other js files. But, whenever I am trying to call any function.then the highest parameterized function is getting called every time.
reusefun.js
exports.getMessage = function(val1) {
return val1;
}
exports.getMessage = function(val1,val2) {
return val1+ " " +val2;
}
exports.getMessage = function(val1,val2,val3) {
return val1+ " " +val2+ " " +val3;
}
Suppose I am using this file like below
myfile.js
const re = require('./reusefun);
console.log(re.getMessage("a"));
Then getMessage(val1,val2,val3) is getting called instead of getMessage(val1) .