6 ms·
Why is deep copy so essential? Deep copy is the wrong solution to your problem 99% of the time, IMO.
by taco_emoji 9y ago
Why is deep copy so essential? Deep copy is the wrong solution to your problem 99% of the time, IMO.
- frwhlr 9y agoI 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.
- fleitz 9y agoBecause it allows you to keep your shitty mutable functions... because the solution to any problem is never to fix the actual problem but to patch around it...