<html>
<body>
<h1>JavaScript 对象</h1>
<h2>Object.assign() 方法</h2>
<p id="demo"></p>
<script>
// 创建目标对象
const person1 = {
firstName: "Bill",
lastName: "Gates",
age: 19,
eyeColor: "blue"
};
// 创建源对象
const person2 = {firstName: "Anne", lastName: "Smith"};
// 将源对象的属性赋值到目标对象
Object.assign(person1, person2);
// 显示目标对象
let text = Object.entries(person1); // 获取目标对象的键值对数组
document.getElementById("demo").innerHTML = text; // 将结果显示在页面上
</script>
</body>
</html>