let aa = [{'id':111,"name":"aa1"},{'id':222,"name":"aa2"}]
let arr = []
var obj = {
id: "",
name:""
}
aa.forEach((item) => {
obj.id = item.id;
obj.name = item.name;
arr.push(JSON.parse(JSON.stringify(obj))); //深拷贝
})
console.log(arr);
js中对象,需要考虑深拷贝,浅拷贝的概念。