Object.assign(target, ...sources) คัดลอก Property จาก Source ไป Target เรียก Getter/Setter
ตัวอย่างโค้ด
var object = {first: second => second + 1000};
var object2 = Object.assign({}, object);
console.log("The result=");
console.log(object2.first(1000));
วิธีรันโปรแกรม
ใช้คำสั่ง node fileName.js (เช่น node demo102.js)
ผลลัพธ์
The result= 2000
หมายเหตุ: เป็น Shallow Copy Nested Object จะยังอ้างอิงตัวเดิม