javascript shallow copy code example
Example 1: javascript deep clone
var cloned = JSON.parse(JSON.stringify(objectToClone));
Example 2: js shallow copy
Object.assign({}, obj); // ES6 shallow copy
var cloned = JSON.parse(JSON.stringify(objectToClone));
Object.assign({}, obj); // ES6 shallow copy