I guess it wouldn't be hard in Javascript to create a decorator object that wraps your list / array where you get an error or no-op if you try to mutate it.
That would have the advantage of not needing to copy a potentially huge object.
(though map/reduce/etc.. generally do make copies or at least "stream" the new values)
I'd call that a "defensive copy" rather than being inmutable.
Thank you comment!
Right! strictly speaking, it's not immutable. I didn't know the word "defensive copy".
I guess it wouldn't be hard in Javascript to create a decorator object that wraps your list / array where you get an error or no-op if you try to mutate it.
That would have the advantage of not needing to copy a potentially huge object.
(though map/reduce/etc.. generally do make copies or at least "stream" the new values)
inmutable would be interesting though.. I have no idea how to do that.