我必须在asp.net 中制作一个动态图。为此,我需要这种类型的数据结构:- [[0, 0, 8], [0, 1, 2], [0, 2, 7] 数组内数组,
我使用了 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 '现在2:-[0,1,2,3,4,5] 现在 1:-[0,1,2,0,1,2] 现在3:-[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>
关于javascript - 要在 asp.net 中创建图形,我需要数组内部数组格式的数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34960391/