I am working with Google Sheets API and I want to de-structure an array of arrays to get the headers and the data. I know that the headers are in data[0]
and the rest are the row values.
var data = [
["header 1", "header 2", "header 3"],
["data 1.1", "data 1.2", "data 1.3"],
["data 2.1", "data 2.2", "data 2.3"],
["data 3.1", "data 3.2", "data 3.3"],
["data 4.1", "data 4.2", "data 4.3"],
]
var [header, ...rowValues] = [data[0], data]
How do it tell that the rest of the arrays should be assigned to the rowValues
.
I can solve by rowValues.push()
in a for
loop that starts on data[1]
but that would be unelegant.