1// Syntax:
2let newClone = node.cloneNode([deep])
3
4// Example:
5let p = document.getElementById("para1")
6let p_prime = p.cloneNode(true)
1var x = {myProp: "value"};
2var xClone = Object.assign({}, x);
3
4//Obs: nested objects are still copied as reference.
1var sheep={"height":20,"name":"Melvin"};
2var clonedSheep=JSON.parse(JSON.stringify(sheep));
3
4//note: cloning like this will not work with some complex objects such as: Date(), undefined, Infinity
5// For complex objects try: lodash's cloneDeep() method or angularJS angular.copy() method