I have a two dimensional array in a Google apps script
data = [[1, 2], [3, 4]];
Trying to get the length of data returns "Undefined". Why is that?
Logger.log(data.length) // Outputs "Undefined"
Update (full code):
data = sheet.getSheetValues(1, 1, 10, 2);
Logger.log("readSpreadSheet");
Logger.log(data);
Logger.log(data.length);
Log:
[14-02-10 15:05:05:592 CET] readSpreadSheet
[14-02-10 15:05:05:592 CET] [[tt0062622, 10.0], [tt0066921, 10.0], [tt0094721, 8.0], [tt0445934, 10.0], [tt0784972, 7.0], [tt1136608, 1.0], [tt0119116, 10.0], [tt1195478, 7.0], [tt2234155, 1.0], [tt1675434, 9.0]]
[14-02-10 15:05:05:592 CET] undefined
I have a two dimensional array in a Google apps script
data = [[1, 2], [3, 4]];
Trying to get the length of data returns "Undefined". Why is that?
Logger.log(data.length) // Outputs "Undefined"
Update (full code):
data = sheet.getSheetValues(1, 1, 10, 2);
Logger.log("readSpreadSheet");
Logger.log(data);
Logger.log(data.length);
Log:
[14-02-10 15:05:05:592 CET] readSpreadSheet
[14-02-10 15:05:05:592 CET] [[tt0062622, 10.0], [tt0066921, 10.0], [tt0094721, 8.0], [tt0445934, 10.0], [tt0784972, 7.0], [tt1136608, 1.0], [tt0119116, 10.0], [tt1195478, 7.0], [tt2234155, 1.0], [tt1675434, 9.0]]
[14-02-10 15:05:05:592 CET] undefined
Share
Improve this question
edited Jun 20, 2022 at 8:57
Anthony Main
6,06812 gold badges66 silver badges89 bronze badges
asked Feb 10, 2014 at 14:02
norqnorq
1,4343 gold badges21 silver badges37 bronze badges
3
- 1 Are you sure your variable in scope? Show us the rest of the code. – helderdarocha Commented Feb 10, 2014 at 14:10
- 1 Print out the value of data. – James Black Commented Feb 10, 2014 at 14:11
- Updated. This is how it's supposed to work in JS right? Maybe it's a Google AS bug :/ – norq Commented Feb 10, 2014 at 14:22
1 Answer
Reset to default 12You made a typo in your code...
you wrote lenght
instead of length
code :
data = sheet.getSheetValues(1, 1, 10, 2);
Logger.log("readSpreadSheet");
Logger.log(data);
Logger.log(data.length);
log:
data.length = 10