3 ms·
I think spamming mutable objects around in your codebase is asking for trouble. I'd be really happy to be able to do something like this: foo( Object.copy(ba
by frwhlr 9y ago
I think spamming mutable objects around in your codebase is asking for trouble. I'd be really happy to be able to do something like this:
foo( Object.copy(barObj) );
I mean, why would you send your state's mutable object as argument if you're 100% sure you don't want it to be changed?
- taco_emoji 9y agoBecause copying is expensive. If mutability is the issue, use Object.freeze(), or define properties with Object.defineProperty() setting writable to false.