Reputation: 25028
I have to make template modules, each of which has 3 functions. For example, there can be module1.js
which will have exports.function1
, exports.function2
and exports.function3
. There will be module2.js
which also has the exact same functions; just the functionality would differ.
I use WebStorm for development and when I type exports.
, it gives me the 3 function names as autocomplete suggestions.
My question is, will these functions overwrite each other? Or is it okay to have same function names in different modules?
Upvotes: 1
Views: 30
Reputation: 19040
There is no issue if you use the same name: exports
is, at core, a simple object, and this is perfectly fine:
var obj = {a: 1};
var obj2 = {a: 2};
console.log(obj.a + obj2.a); // prints... 3!
The reason WebStorm shows the three functions is because it's unable to statically determine which are actually available. If you run the code, you'll confirm it.
Upvotes: 1