I am new to JS and need some basic help:
I have a spreadsheet which has a square matrix of data.
I can read these data as follows:
var freqArr = new Array(new Array());
var freqSheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("freq");
var freqRows = freqSheet.getDataRange();
var freqNumRows = freqRows.getNumRows();
freqArr = freqSheet.getRange(2, 2, freqNumRows, freqNumRows).getValues();
I now want to create a an array in memory similar to the one I have read from the sheet
var tempArr = new Array(new Array());
for (var i = 0; i <= 3; i++) {
for (var j = 0; j <= 3; j++) {
tempArr [i][j] = freqArr[i][j] ;
}
}
As soon as j incs from 0 to 1 and I try to store anything in tempArr [i][j] I get an error "TypeError: Cannot set property "0.0" of undefined to "xxx"
I have tried every combination of creating tempArr that I can think of plus a few more.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…