我必须在asp.net中制作一个动态图。为此,我需要这种类型的数据结构:-[[0,0,8],[0,1,2],[0,2,7] array在array内部,

我用过array.push,但是将我的数据集转换成这种格式:

 'for (var i = 0; i < forth.length; i++)
      {
         result.push([present2[i], present1[i], present3[i]]);
      }
  [0, 0, 8, 0, 1, 2, 0, 2, 7].'


我有3组数组:present2,present1,present3
     'present2:-[0,1,2,3,4,5]
      present1:-[0,1,2,0,1,2]
      present3:-[8,2,7,1,4,2]'

现在我想使用它们来创建这种类型的结构
      '[[[0,0,8],[0,1,2],[0,2,7]]'
我怎样才能做到这一点?

最佳答案

var present2=[0,1,2,3,4,5], present1=[0,1,2,0,1,2] ,present3=[8,2,7,1,4,2];
var result=[];
for (var i = 0; i < present2.length; i++)
{
   result.push([present2[i], present1[i], present3[i]]);
}
console.log(result);

document.getElementById("output").innerHTML=JSON.stringify(result);

<div id="output"></div>

10-06 00:50