es6 object copy code example
Example 1: copy object javascript
// es6
const obj = {name: 'john', surname: 'smith'};
const objCopy = {...obj};
Example 2: javascript clone object
var x = {myProp: "value"};
var xClone = Object.assign({}, x);
//Obs: nested objects are still copied as reference.