DEV Community

Discussion on: How to manipulate immutably and mutably JavaScript Array with only ES6+

Collapse
 
aminmansuri profile image
hidden_dude

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)