I want to make an array flat.
// example of the start array
const myArray = [
[
{ foo: "bar", baz: "qux"},
{ quux: "corge", grault: "garply" }
],
[
{ waldo: "fred", plugh: "xyzzy" },
{ thud: "barbra", streisand: "woohoo" }
]
];
However I'd like it to be:
// end result
[
{ foo: "bar", baz: "qux"},
{ quux: "corge", grault: "garply" },
{ waldo: "fred", plugh: "xyzzy" },
{ thud: "barbra", streisand: "woohoo" }
]
Now the following example gives the result: (2) [Array(2), Array(2)]
.
const myArray = [
[
{ foo: "bar", baz: "qux"},
{ quux: "corge", grault: "garply" }
],
[
{ waldo: "fred", plugh: "xyzzy" },
{ thud: "barbra", streisand: "woohoo" }
]
];
let newArray = [];
myArray.forEach((subArray) => newArray.push(subArray));
console.log(newArray);