我想談談這個:如何變換數組對象
let myArray = [ {city: "NY"}, {status: 'full'} ];
這樣:
let myObj = { city: "NY", status: 'full' };
而我嘗試這樣做:
let newObj = {};
for (var i = 0; i < myArray.length; i++) {
(function(x) {
newObj = Object.assign(myArray[i]);
})(i);
}
它分配最後一對對象
你請求的對象是無效的;你不能有'{{city:'NY'}}' –