News for hackers. Stuff that matters.
Re:Deep Cloning Objects in JavaScript, the Modern Way by _a_a_a_ on Thursday December 21, 2023 @08:12PM (#38729625)
By deep-copying it, right? Sometimes it is needed.
Re:Deep Cloning Objects in JavaScript, the Modern Way by WendyTheWillow on Thursday December 21, 2023 @08:47PM (#38729922)
…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.
Re:Deep Cloning Objects in JavaScript, the Modern Way by jcparkyn on Thursday December 21, 2023 @10:25PM (#38730621)
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.
Re:Deep Cloning Objects in JavaScript, the Modern Way by qayxc on Friday December 22, 2023 @06:16AM (#38733119)
The Date object would like to have a chat with you ;)
Re:Deep Cloning Objects in JavaScript, the Modern Way by jcparkyn on Thursday December 28, 2023 @06:55PM (#38800229)
I know you were mostly joking, but for cloning dates you can "just" use the constructor (https://stackoverflow.com/a/69601256).