首页 > 其他分享 >数据处理

数据处理

时间:2022-11-28 17:11:06浏览次数:33  
标签:11 10 01 item lastMonth 2022 数据处理

      d变成dd
let d = { currentMonth: { "2022-11-01": 11, "2022-11-02": 43, "2022-11-03": 53, "2022-10-05": 23, }, lastMonth: { "2022-10-01": 4, "2022-10-04": 3, "2022-10-05": 13, "2022-11-01": 19, }, }; let dd = [ [ "2022-10-01", "2022-10-04", "2022-10-05", "2022-11-01", "2022-11-02", "2022-11-03", ], //本月 [0, 0, 23, 11, 43, 53], //上月 [4, 3, 13, 19, 0, 0], ]; const arr = [ ...Object.keys(d.currentMonth), ...Object.keys(d.lastMonth), ]; const newArr = [...new Set(arr)].sort(); const arr1 = [], arr2 = []; newArr.forEach((item) => { if (d.currentMonth[item]) arr1.push(d.currentMonth[item]); else arr1.push(0); if (d.lastMonth[item]) arr2.push(d.lastMonth[item]); else arr2.push(0); }); // console.log(1111, [newArr, arr1, arr2]);

 

标签:11,10,01,item,lastMonth,2022,数据处理
From: https://www.cnblogs.com/Byme/p/16932684.html

相关文章