const obj = {name:'James',age:25};const address = [{add1:'USA'},{add2:'UK'}]Expecting : obj={name:'James',age:25,tag:[{add1:'USA'},{add2:'UK'}]};试过对我不起作用Object.entries(address).forEach(([key,value]) => { obj[key] = value })
1 回答
慕森卡
TA贡献1806条经验 获得超8个赞
let obj = {name:'James',age:25};
let address = [{add1:'USA'},{add2:'UK'}];
obj['tag'] = [...address];
const resultObj = obj;
console.log(resultObj);
添加回答
举报
0/150
提交
取消