I have following array:
[
[val1, val2]
[val1, val2]
[val1, val2]
[valN, valN]
]
N represents the fact that the
You can use Array#map to achieve this. Array#map passes each array element through a projection function and returns the values in a new array.
var data= [
['val1', 'val2'],
['val1', 'val2'],
['val1', 'val2'],
['valN', 'valN'],
];
var result = data.map(function(row) {
return {
lat: row[0],
lng: row[1]
};
});
console.log(result);