Reputation: 131
var example
is a 2-dimension array. example.length
will give values like 14.3
But how can I get an integer for the length of example
in second dimension, like 3 in this case?
Thank you!
Upvotes: 1
Views: 11191
Reputation: 46802
If the array is homogeneous (which is always the case when such an array is the result of a getValues()
call in a spreadsheet range for example) you can simply write :
example[0].length
EDIT : a few comments to be more clear ...
The 2D array you get from example = range.getValues()
is always an array of rows data.
The number of rows is represented by example.length
and the inner array length (representing rows content) is always example[0].length
, which is actually the number of columns
Upvotes: 2