DEV Community

Discussion on: Deep Copying in JavaScript just in few minutes

Collapse
 
ll profile image
Lorenzo Lomartire

To deep copy an object I prefer using:
var deepcopy = {...original, ...JSON.parse(JSON.stringify(original))};
because it copies also methods, not only properties.

Collapse
 
muhammad_asif profile image
Muhammad Asif

well said