1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| // 建立目標對象 const person1 = { firstName: "John", lastName: "Doe", age: 50, eyeColor: "blue" };
// 建立來源物件 const person2 = {firstName: "Anne",lastName: "Smith"};
// 將來源分配給目標 Object.assign(person1, person2); console.log(person1) // 顯示目標 let text = Object.entries(person1);
document.getElementById("demo").innerHTML = text;
|