Hacker News new | ask | show | jobs
by evincarofautumn 3943 days ago
How do you mean? All this post is saying is that “const” in JavaScript is the same as “final” in Java—it lets you make immutable references, but not immutable objects. In C terms, you can express this:

    T *const x = ...;  // Immutable pointer to mutable T.
But not this:

    T const *x = ...;  // Mutable pointer to immutable T.
Even so, I don’t agree with the author’s argument that “const” is to be avoided. It does offer some protection against minor errors, which is not nothing.
1 comments

I don't think my argument was to avoid `const`. I think my argument was to pick `const` at the end rather than at the beginning. I feel those are different arguments.
To be clear, “choose X last” does give the impression of “avoid X”, by which I don’t mean “don’t use X at all”. I disagree, but it’s a small matter; it’s not as if it would bother me to read your code.