JavaScript 2025 · Arrays
Map and flatten in one step
Collect the tags of every post into a single array.
const tags = posts.flatMap((post) => post.tags);
Official JavaScript 2025 documentation
JavaScript 2025 · Arrays
Collect the tags of every post into a single array.
const tags = posts.flatMap((post) => post.tags);
Official JavaScript 2025 documentation
Was this page helpful?