Categories
JavaScript Answers

How to flatten an array of arrays of objects with JavaScript?

Spread the love

To flatten an array of arrays of objects with JavaScript, we use the flat method.

For instance, we write

const flattened = [["object1"], ["object2"]].flat();

to return a flattened version of the [["object1"], ["object2"]] array with flat.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *