Re:Deep Cloning Objects in JavaScript, the Modern Way
by endisneigh on Thursday December 21, 2023 @07:08PM
(#38729002)
There are plenty of reasons to deepclone. That being said I do share some agreement. JavaScript imo is best when you limit complex structures and stick with primitives, ideally just one layer deep, but there are situations when it can’t be helped, e.g, dealing with api calls.
[ Parent
| on HN ]
Re:Deep Cloning Objects in JavaScript, the Modern Way
by chatmasta on Thursday December 21, 2023 @07:11PM
(#38729047)
Yep. But API calls traverse the network, and assuming that's via JSON, you're already losing functionality like Date parsing, so the litmus test of JSON.stringify/parse seems appropriate to determine if you're dealing with a true "data object." If you run into issues with things like Dates, then it's a smell indicating a potential point of divergence in different codepaths that handle the network call differently.
Re:Deep Cloning Objects in JavaScript, the Modern Way
by endisneigh on Thursday December 21, 2023 @07:16PM
(#38729084)
I don’t disagree, but just responding to your comments first paragraph.