ES6-Object.assign()

 

Object.assignA method for merging the object, the source object (source) of all enumerated attribute, copied to the target object (target).

const target = { a: 1, b: 1 };

const source1 = { b: 2, c: 2 };
const source2 = { c: 3 };

Object.assign(target, source1, source2);
target // {a:1, b:2, c:3}

 

Reference documents: https://www.jianshu.com/p/d5f572dd3776

 

Guess you like

Origin www.cnblogs.com/XUYIYUAN/p/12662075.html