合并对象,将 person1和person2
const person1={name:'张三',age:20}
const person2= {name:'李四',hobby:['读书','看报']}
const person = Object.assign(person1,person2)
console.log(person)
结果为
{name:'李四',age:20,hobby:['读书','看报']}
如果源对象有重复属性,则保留后面对象的属性,即person1,person2 中都有age属性,则保留person2中的age属性和值