et obj ={"a":1,"b":2} let n = {}; let m = []; for(let i in obj){ n.name = i; n.number =obj[i]; } console.log(n) => {name: "b", number: 2}, 如何改进,让m 的结果是 [{name: "a", number: 1},{name: "b", number: 2}]
1 回答
达令说
TA贡献1821条经验 获得超6个赞
let obj ={"a":1,"b":2}
let m = [];
for(let i in obj){
m.push({name: i, number: obj[i]})
}
console.log(m)
添加回答
举报
0/150
提交
取消