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
Using a combination of map and forEach you can map the subsequent array elements to the columns specified in the first element.
var arr = [
['country', 'population'],
['someplace', 100],
['otherplace', 200]
];
var cols = arr.shift();
newArr = arr.map(function(element,index){
var newObj = {};
element.forEach(function(data,index){
newObj[cols[index]]=data;
});
return newObj;
});