當我嘗試創建使用循環JavaScript的二維數組,它給了我以下錯誤:二維數組填充不工作的JavaScript
Cannot set property 'indexis' of undefined
代碼:
var indexes = [];
for (var i = 0; i < headingsArray.length; i++) {
if (headingsArray[i].toLowerCase().indexOf('name') != -1) {
indexes[i]['indexis'] = i;
indexes[i]['headingis'] = headingsArray[i]; //assuming headingsArray exist
indexes[i]['valueis'] = rows[0][i]; //assuming rows exist
}
}
多維數組在JavaScript中有時是一種痛苦.. https://stackoverflow.com/questions/966225/how-can-i-create-a-two-dimensional-array-in-javascript –