News for hackers. Stuff that matters.
Re:Deep Cloning Objects in JavaScript, the Modern Way by rabbits_2002 on Friday December 22, 2023 @01:28AM (#38731533)
I agree that its weirdly difficult but if you are trying to deep clone an object, you are probably doing something wring
Re:Deep Cloning Objects in JavaScript, the Modern Way by WA on Friday December 22, 2023 @01:33AM (#38731556)
Not at all. It’s common to have nested data, it can be quite simple, but still nested. Think: config objects, simple state objects. I want my functions to be pure. Instead of modifying the nested object, they should return a modified deep copy.
Re:Deep Cloning Objects in JavaScript, the Modern Way by lambda_garden on Friday December 22, 2023 @05:26AM (#38732856)
Use the spread syntax to make a shallow copy; it's more performant.