What do you guys think about making constants in Javascript. I want to do it in the best possible way. I know that constants do not really exist but I wrote this and I was not able to change the values after the export.
Is there a need for constants?
Is there a work around?
How can we use them global (without require('const')); ?
// Const
var constants = {
'PATH1' : __dirname + '/path..../',
'PATH2' : __dirname + '/path/..../'
};
module.exports = function(key) {
return constants[key];
};
//console.log(constants('PATH1'));
Would be glad if I get some feedback, like your thoughts about these questions.
I wish you a good day.