cachaito
2/11/2019 - 3:03 PM

copy objects ES6

var obj = {
  id: 1,
  name: 'XXX'
};

//1 
var newObj = {...obj};

//1b
var newObj2 = {...obj, anotherProp: 'YYY'};

//2
var newObj3 = Object.assign({}, obj, {anotherProp: 'YYY'});