[英]How can I get the iteration of the first array index in a map?
在下面的代碼中,curveData是一個二維數組。 如何在地圖中獲取第一個數組索引的迭代?
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};
});
});
在上面的代碼中,j是二級索引。
例如:
curveData[i][j]
我正在進行j迭代但是如何訪問i迭代?
要獲取外部索引,只需在頂級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.