Is it possible to simulate constants in Javascript using closures? If so, can you please furnish me with an example?
To declare :
function globals(){ const x1="something"; const x2="otherthing"; return{ getX1=function(){ return x1; }, getX2=function(){ return x2; } } } var globalConstants=globals();
To access :
globalConstants.getX1();