[英]How can I get the iteration of the first array index in a map?
In the following code curveData is a 2 dimensional array. 在下面的代码中,curveData是一个二维数组。 How can I get the iteration of the first array index in a map?
如何在地图中获取第一个数组索引的迭代?
curveData.map(function(d) {
return d.map(function(count, j) {
console.log('d:'+d+', j:'+j+', count:'+count);
return {x:j, y:count, y0:0};
});
});
In the code above j is the secondary index. 在上面的代码中,j是二级索引。
For example: 例如:
curveData[i][j]
I am getting the j iteration but how can I access the i iteration? 我正在进行j迭代但是如何访问i迭代?
To get the outer index, you just need to include the index parameter in your top level map
: 要获取外部索引,只需在顶级
map
包含index参数:
curveData.map(function(d, i) {
return d.map(function(count, j) {
console.log(curveData[i][j]);
console.log('d:'+d+', j:'+j+', count:'+count);
return {x:j, y:count, y0:0};
});
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.