I have an an array of objects and arrays of objects
const a = [[{'k': 'b'}, {'a1': 'c1'}], {'a': 'c'}];
And what I want to have is just array of objects, like
const a = [{'k': 'b'}, {'a1': 'c1'}, {'a': 'c'}];
I tried to sort out element of a
, which are arrays (0 element in this example) and pull out objects separately
const a_arr = [];
for (let i = 0; i < a.length; i++) {
for(let j = 0; j < a[i].length; j++) {
a_arr.push(a[i][j]);
}
}
It works fine, but I don't know what must be my second step? I need to pull out from array just objects (in this case a[1]) and then concat to arrays of object, but how could I achieve this?
Or, maybe there is better way to do all this?