Object.defineProperty(window, 'CONSTANT_NAME', {value: CONSTANT_VALUE});
console.log(CONSTANT_NAME);
Object.defineProperty() :
configurable true, .
false.
enumerabletrue if and only if this property appears while enumerating the properties of the corresponding object. The default is false.
writabletrue if and only if the value associated with the property can be changed using the assignment operator. The default is false.
if "constant" is an object that you might want to make it immutable by freezing it. obj = Object.freeze(obj). keep in mind that child-property objects will not be automatically frozen.
source
share