Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Shallow copy Objects using Object.prototype.assign method

var obj = { 
  a: 1,
  b: 2
}

var newObj = _.clone(obj);
obj.b = 20;
console.log(obj); // { a: 1, b: 20 }
console.log(newObj); // { a: 1, b: 2 }
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #Shallow #copy #Objects #method
ADD COMMENT
Topic
Name
8+9 =