(no title)
lambda_garden | 2 years ago
Why does that require deep clones?
I simply do:
return {
...current
foo: "bar"
};lambda_garden | 2 years ago
Why does that require deep clones?
I simply do:
return {
...current
foo: "bar"
};
VPenkov|2 years ago
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.
Drakim|2 years ago
Maybe it's not a situation that comes up often, but it would be fairly hard to debug and guarding yourself against mysterious problems in advance is always neat.
lambda_garden|2 years ago