Coming from other languages I was holding the same prejudice, a source of continual annoyance.
Until I finally realized it meant "constant binding", not "constant value".
All of a sudden from that perspective the behaviour is entirely consistent.
A lot of things start to make sense when one takes into account that Brendan Eich was hired for "doing Scheme in the browser" but then had to comply with the "diktat from upper engineering management was that the language must 'look like Java'."
We also have Java to blame for null entering into the language. One bottom-most value (undefined) ought to be enough.
I've been a professional C, Perl, PHP and Python developer.
I'm an ex-sysadmin from the late 20th century.
These days I do more Javascript and CSS and whatnot, and promote UX and accessibility.
But I imagine that the whole primitive values are immutable thing was established much, much earlier—leading to a situation where creating a "constant binding" was easy and relatively cheap in terms of run-time performance.
Facilities for creating immutable objects exist (Object.freeze() which is only shallow) but come with run-time overhead.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Coming from other languages I was holding the same prejudice, a source of continual annoyance.
Until I finally realized it meant "constant binding", not "constant value".
All of a sudden from that perspective the behaviour is entirely consistent.
A lot of things start to make sense when one takes into account that Brendan Eich was hired for "doing Scheme in the browser" but then had to comply with the "diktat from upper engineering management was that the language must 'look like Java'."
We also have Java to blame for
null
entering into the language. One bottom-most value (undefined
) ought to be enough.Wasn't
const
added waaaay later though, like in ~2010 or something?ES2015 (ES6) actually.
But I imagine that the whole primitive values are immutable thing was established much, much earlier—leading to a situation where creating a "constant binding" was easy and relatively cheap in terms of run-time performance.
Facilities for creating immutable objects exist (
Object.freeze()
which is only shallow) but come with run-time overhead.