News for hackers. Stuff that matters.
Re:Deep Cloning Objects in JavaScript, the Modern Way by VPenkov on Friday December 22, 2023 @07:03AM (#38733349)
I'm not sure if you're asking why deep copies are useful or something else.

Maybe you're handing over your data to a library developed by someone else and you want to make sure the library cannot mutate your original data, so you opt to pass a deep copy instead. Or maybe you are the author of said library and you want to make sure you preserve the original data so you copy it on input rather than on output.

There are many situations where deep-copying is useful but I agree that you should use the simplest pattern that works for your use-case.

There are no comments on this comment yet.