I am trying to avoid using global variables in my server.js file but need variables accessible and writable by various functions. However, I am unsure if scope works the same way as on the client side (since it seems more 'hidden'). I read somewhere that modules have their own scope but if I place variables there and they are accessible in server.js isn't that the same thing as a global scope? For example:
//module.js var config = [ {var1: 1}, {var2: 2}, {var3: 3} ] module.exports = { config }; //server.js const { config } = require("./config.js") function function1() { var a = config[0].var1 bar b = config[0].var2 config[0].var3 = a+b // changing var3 value in module } Is using modules this way acceptable? If not what would be considered a better practice here?
Thanks