Hacker News new | ask | show | jobs
by WendyTheWillow 905 days ago
Or use a library that doesn’t modify the input…
1 comments

By deep-copying it, right? Sometimes it is needed.
If 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.
The Date object would like to have a chat with you ;)
I know you were mostly joking, but for cloning dates you can "just" use the constructor (https://stackoverflow.com/a/69601256).
…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.