const + Object.freeze is a lot to remember and cumbersome to use throughout a codebase, very relevant to Carmack's wish for immutability by default. I'm grateful Rust opted for that default.
Fair enough about const and let, the obnoxiousness for me is a combination of the language ergonomics, language ecosystem, but mostly the techno-political decision making behind it.
Neither let nor even const are immutable (const prevents reassignment but not mutation if the value is of a mutable type like object or array).
Yep, I believe you'd need to call Object.seal(foo) to prevent mutability. Haven't really had the chance to use it
Object.freeze is the one you're looking for.
const + Object.freeze is a lot to remember and cumbersome to use throughout a codebase, very relevant to Carmack's wish for immutability by default. I'm grateful Rust opted for that default.
Fair enough about const and let, the obnoxiousness for me is a combination of the language ergonomics, language ecosystem, but mostly the techno-political decision making behind it.
well yeah except const doesn't make objects or arrays immutable
Yeah it makes their structure immutable? Something like that. Not useless but not what you would expect.
But for non-objects and non-arrays it's fine.
I feel that Java’s “final” would have been a better choice than “const”. It doesn’t have the same confusing connotation.