Append Multi-Dimension Arrays Horizontally in Blocks

后端 未结 2 856
别跟我提以往
别跟我提以往 2021-01-29 08:28

I have several Multi-Dimension Arrays, that I wish to concatenate horizontally. Thinking of the Multi-Dimension Arrays as tables, I want to append each by stacking them horizont

2条回答
  •  梦如初夏
    2021-01-29 09:08

    Here's a version with map.

    const arr1 = [["A1","B1","C1","D1"],["A2","B2","C2","D2"]]
    const arr2 = [["E1","F1","G1","H1"],["E2","F2","G2","H2"]];
    
    const out = arr1.map((arr, i) => {
      return arr.concat(arr2[i]);
    });
    
    console.log(out);

提交回复
热议问题