0

How to deep copy an object along with methods provided in it. if it nested means in a key value pair value itself is an object.

In deep copying we should not have the reference of previous object in our new copy anywhere.manipulsting copy should not affect the original object.

23rd Apr 2020, 5:06 PM
Ashish Kumar
Ashish Kumar - avatar
2 Respuestas
+ 1
Scroll down and check out "Deep copy with custom function 3" if you don't want to use a library. It's fine for smaller to mid sized arrays and objects but it is a bit slow. If you need to use with large to very large objects or arrays, I would suggest you use #5 library "rfdc". https://medium.com/javascript-in-plain-english/how-to-deep-copy-objects-and-arrays-in-javascript-7c911359b089
23rd Apr 2020, 7:13 PM
ChaoticDawg
ChaoticDawg - avatar
+ 1
Thanks..that was really helpful..rfdc is fastest fron all those libraries.
23rd Apr 2020, 7:41 PM
Ashish Kumar
Ashish Kumar - avatar