如何将3维数组转换为2维

时间:2019-07-11 03:38:34

标签: javascript arrays

let arr = [ [ [ 11, 12 ], [ 5, 3 ] ],
          [ [ -0.3, 12 ], [ 5, 1 ] ],
          [ [ -0.16, 12 ], [ 6.44, 17 ] ],
          [ [ -0.16, 12 ], [ 7.79, 17.14 ] ],
          [ [ -0.1, 12 ], [ 7.4, 16.8 ], [ 7.45, 1 ] ],
          [ [ -0.1, 12 ], [ 8, 17 ], [ 8, 17 ] ] ]

let output =  [ [ 11, 12 ], [ 5, 3 ] ],
          [ [ -0.3, 12 ], [ 5, 1 ] ],
          [ [ -0.16, 12 ], [ 6.44, 17 ] ],
          [ [ -0.16, 12 ], [ 7.79, 17.14 ] ],
          [ [ -0.1, 12 ], [ 7.4, 16.8 ], [ 7.45, 1 ] ],
          [ [ -0.1, 12 ], [ 8, 17 ], [ 8, 17 ] ]
  

在此处输入代码

我想将3维数组转换为2维数组。我不想将它们合并到一个数组中。我只想删除外括号[]并保持其内部相同。

0 个答案:

没有答案