3 ms·
Sure! Use a library that deep-clones the object first, leaving the original parameter unchanged! And now it's slower than the original library you're criticisin
by _a_a_a_ 3y ago
Sure! Use a library that deep-clones the object first, leaving the original parameter unchanged! And now it's slower than the original library you're criticising.
- WendyTheWillow 3y agoOr use a library that doesn’t modify the input…
- _a_a_a_ 3y agoBy deep-copying it, right? Sometimes it is needed.
- WendyTheWillow 3y ago…the whole thread you’re replying to is about it not actually being necessary. To participate in this conversation you either accept that premise or disagree with it, passing it as a given is not really an option for the argument.
- jcparkyn 3y agoIf you know what modifications you need to make (hopefully the library author does), you only need to clone the relevant parts of the object (e.g. with spreading). Deep cloning still isn't usually necessary unless you're doing wierd stuff.