First, I had asked is it possible: How to create Javascript constants as properties of objects using const keyword?
Now, I gotta ask: why? The answer to me seems to be ‘just because’, but it would be so useful to do something like this:
var App = {}; // want to be able to extend
const App.goldenRatio= 1.6180339887 // throws Exception
Why can constants set on an activation object work but not when set on they are set on any other?
What sort of damage can be done if this were possible?
What is the purpose of const, if not to prevent a public API from being altered?
Going to answer the question you meant to ask and say never use
const. The interpreter doesn’t do anything with it. All it does is mislead the developer into thinking s/he can assume that the value never changes, which is about as likely as if theconstkeyword weren’t present.