我有一个将对象复制到数组的问题。我认为这是一个参考问题。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返回任何东西? –