Where are constants created in a global scope stored in JavaScript?
For example, if I create a variable using: var var_example = '123'
, I can access it by window.var_example
.
However, if I create a const variable using: const const_example = '456'
, then how do I access it?
I need this to create an immutable/read-only global variable in a function.
I can create an ordinary global variable in a function using: window.in_function_var = 'global variable'
, but I don’t know how to create a constant/immutable/read-only global variable in a function; it seems to me that this can be done by accessing a scope with constants and adding the desired variable there.