[Proposal] Make const object immutable

If I declare an object using const, I shouldn’t be able to use push(), pull(), shift(), nor slice() on it for it to be truly immutable.

1 Like
  1. This would be a breaking change, which is a non-starter.
  2. Use Object.freeze and Object.seal to do what you want.
4 Likes

that’s amazing. Thank you for that!

const means the binding can’t change, but it doesn’t say anything about the object that is assigned to that binding. That’s just how this feature was defined.

That being said, it may be useful to have a way to declare a variable whose value is automatically immutable. Something like:

ice arr = [1, 2, 3];

Or not, I don’t really know :sweat_smile:

1 Like