我有一個將對象複製到數組的問題。我認爲這是一個參考問題。Js從陣列中複製對象而無需參考
在我的程序中,我有幾個數組。首先是dataForMonth - 它是包含月份數據的對象數組。其次是包含產品對象的產品數組。產品具有屬性預測設置對象數組。
下面的代碼:
this.allProducts.map(function (product) {
var dataForMonth = data.filter(function (e) {
return e.dataId === product.productDataId;
});
var z = { posId: product.sales_plan_pos_id, arry: [] }
for (var sheetMonth of sheet.channels) {
var result = dataForMonth.filter(function (e) {
return e.CHANNEL === sheetMonth.CHANNEL;
});
product.forecastArry[someId].channels = result;
);
的問題是,每一個改變信道特性具有相同的價值 - 它從去年的產品價值? 有人知道如何解決它?
聽起來像一個dup http://stackoverflow.com/questions/28150967/typescript-cloning-object –
爲什麼不回電話funer返回任何東西? –