Convert array of arrays into multidimensional array in Typescript -
i'm trying convert array of arrays requested http service. have following code below:
this array http service have number of arrays:
[object array] > [0] > make: "toshiba", model: "h2000" ..[n]
this needs converted multidimensional array this:
[{make:"toshiba"},{model:"h2000"}, {make:"hp"},{model:""}];
i have looked loop having no luck:
create method converts object array
function objtoarray(obj) { return object.keys(obj).reduce(function(arr, key) { arr.push({ [key] : obj[key] }); return arr; }, []); }
and run array through it:
var formattedarray = arr.map(x => objtoarray(x));
Comments
Post a Comment