In order to populate a data-grid that receives array of row objects, I am looking for a good solution to convert an array such as this:
[
[\'country\', \'p
function toObjects (array) {
var new_array = [];
var headers = [];
for(var i = 0; i < array.length; i++){
var obj = {};
for(var j = 0; j < array[i].length; j++){
if(i === 0){
headers.push(array[i][j]);
} else {
obj[headers[j]] = array[i][j];
}
}
if(i > 0){
new_array.push(obj);
}
}
return new_array;
}