两个数组中的 项 合并成 一个新数组

const datas = {
      3: [0, 0],
      4: [874, 1351],
      5: [840, 1369],
      6: [828, 1383],
      7: [821, 1388],
      8: [812, 1384],
      9: [806, 1384],
      10: [801, 1382],
      11: [805, 1386],
      12: [795, 1394]
    };
    const valuesList = Object.values(datas);
    const keysList = Object.keys(datas);
    var arr1 = valuesList; // 定义数组
    var arr2 = keysList; // 定义数组
    var arr3 = []; // 定义数组
    var arr4 = [];
    arr1.map((item, index) => {
      arr3.push({ x: item[0], y: item[1] });
    });
    arr2.map((item, index) => {
      arr4.push({ index: item });
    });
    arr4.map((item, index) => {
      arr3[index].index = item.index;
    });

 

 

 
posted @ 2022-04-27 16:39  小小小小小前端  阅读(310)  评论(0)    收藏  举报