The code is as follows:
Deepcopy:function (obj) { return _.isobject (obj)? Json.parse (json.stringify (obj)): obj;},
Reproduced as follows:
Pasted over the format is chaotic: The original in this: http://blog.sibo.me/2014/08/20/javascript-deep-clone.html
Conclusion
Deep cloning is a complex task, and there is no perfect solution to be treated with caution.
If it is a simple scenario, it can be done using Json.parse (json.stringify (obj)).
Manual cloning is the safest and most efficient way to fully understand the data structure of an object.
Reference
- Http://stackoverflow.com/questions/7914968/cloning-whats-the-fastest-alternative-to-json-parsejson-stringifyx
- What's the difference between a deep copy and a shallow copy?
- Explanation of deep and shallow Copying
- Deep Copy vs JSON Stringify/json Parse
- What's the most efficient-to-clone an object?
Javascript Deep Clone