3 ms·
> normally 'const' would signify that a variable is immutable in just about any other programming language in the world That's not true in Java, C, Ruby, or Pe
by zbentley 8y ago
> normally 'const' would signify that a variable is immutable in just about any other programming language in the world
That's not true in Java, C, Ruby, or Perl (with the 'constant' prag-module), not really true in C++ (unless you're careful), and . . . generally just isn't true in most languages.
While a few languages do add recursive immutability properties to their equivalent of 'const', most languages use the idea of a 'constant' only as a means of prohibiting name re-binding, not data modification. And even then, many languages that only prohibit const re-binding only do so in an optional (i.e. it's a warning) way.
Many of those same languages do support immutable data structures either out of the box or via popular libraries (though in non-compiled language, such structures often come with a performance cost). They just don't call them const[ant]s.
Edit: I'm also curious about how you think 'const' is being abused in JS. I'm not an expert in the language--this is a genuine question; not a veiled disagreement.