var ObjA = {
'name':'张三',
'age':20,
'sex':'男'
}
var ObjB = {
'name':'李四',
'age':25
}
for(let i in ObjB){
this.ObjA[i] = ObjB[i];
}
console.log(ObjA);
console.log(ObjB);
let objA = {
name: '迪丽热巴',
gender: '女',
hobby: '跳舞'
};
let objB = {
name: '迪丽热巴',
gender: '女',
hobby: '跳舞'
nationality: '中国'
};
let obj = {...objA, ...objB};
console.log(obj);