---
title: "A Smarter JavaScript Mapper: array.flatMap()"
url: https://daily.dev/posts/a-smarter-javascript-mapper-array-flatmap--skd3jbknf
source_url: https://dmitripavlutin.com/javascript-array-flatmap/
type: article
source: "JSK"
published: 2022-01-03T12:58:50.920Z
updated: 2022-01-03T12:58:50.920Z
tags: ["javascript"]
reading_time: 4
upvotes: 67
comments: 2
language: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# A Smarter JavaScript Mapper: array.flatMap()

**[JSK](https://daily.dev/sources/jsk)** · 4 min read · 67 upvotes · 2 comments

## Summary

The array.flatMap() method gives you the ability to map, but also to remove or even add new items in the resulting mapped array. By controlling the number of array items you return from the callback, you can do more than simple flattening. The method accepts a second, optional, argument indicating the this value inside of the callback.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://dmitripavlutin.com/javascript-array-flatmap/>

## Community discussion

Top comments from developers on daily.dev.

**@rcottinet** · 0 upvotes

> Good article and simple example to illustrate concept

**@kkurko** · 0 upvotes

> Clear explanation!

## Similar posts on daily.dev

- [Don’t just attend KubeCon \+ CloudNativeCon, Merge Forward your experience\!](https://daily.dev/posts/don-t-just-attend-kubecon-cloudnativecon-merge-forward-your-experience--l0rpp73x8) · CNCF · 0 upvotes · 0 comments
- [Announcing H2 2026 KCDs](https://daily.dev/posts/announcing-h2-2026-kcds-m96goajm1) · CNCF · 1 upvotes · 0 comments
- [Two months of Open Community Groups](https://daily.dev/posts/two-months-of-open-community-groups-asf52zhbs) · CNCF · 0 upvotes · 0 comments

---

Tags: [#javascript](https://daily.dev/tags/javascript)

[View this post on daily.dev](https://daily.dev/posts/a-smarter-javascript-mapper-array-flatmap--skd3jbknf)
