次のようなオブジェクトを取得したとします。
function node(xVal, yVal, nodeType) {
this.xVal = xVal; // x-coordinate of node
this.yVal = yVal; // y-coordinate of node
this.nodeType = nodeType; // node type - outside the scope of this question
}
x x y の仮想平面上に一連のノードを作成しようとして、次のように 2 次元配列を指定しました。
var ROWS = 3; // number of rows in the array
var COLS = 10; // number of columns in the array
var Nodes = new Array(ROWS);
for (var i=0; i < ROWS; i++) {
for (var j=0; j < COLS; j++) {
Nodes[i][j] = new node(0, 0, "Type A");
}
}
上記の組み込み for ループにより、それぞれが「ノード」オブジェクトを持つ 3x10 配列を初期化できると予想していましたが、何かがエラーを引き起こしているようです。1) エラーの原因、および 2) ロジックを改善する方法についてのご意見をお待ちしております。