# Map, Filter and Reduce

> Three list tools. Map changes each item, filter keeps some, reduce makes one value.

**Field:** Software Development  
**Category:** Programming Paradigms  
**Also known as:** Map Filter Reduce, map(), filter(), reduce()

## Think of it like

Think of it like sorting fruit. Peel each one, keep the ripe ones, then blend them into one drink.

## Definition

Map, filter and reduce work through a list without a loop. Map changes every item and gives back a list of the same length. Filter keeps only the items that pass a test. Reduce folds the whole list into one value, like a total. Chained together, they turn many lines of loop code into one readable line.

## Example

Lucy keeps the even numbers from 1 to 4, makes each ten times bigger, then adds them up. The answer is 60.

## Example code

```javascript
[1, 2, 3, 4]
  .filter((n) => n % 2 === 0)
  .map((n) => n * 10)
  .reduce((a, b) => a + b, 0); // 60
```

Keep 2 and 4, make them 20 and 40, add them to get 60.

## Why it matters

These three show up in nearly every language. Reading them fast is a basic skill.

## Common mistake

Using map just to run something on each item and ignoring the new list. Use a plain loop or forEach for that.

## Three principles

- **Map changes.** Same length out.
- **Filter keeps.** Only items that pass.
- **Reduce folds.** Many items, one value.

## Related terms

- [Higher-Order Function](https://learn.benibix.com/term/development/higher-order-function)
- [Lambda Function](https://learn.benibix.com/term/development/lambda)
- [Array](https://learn.benibix.com/term/development/array)
- [Loop](https://learn.benibix.com/term/development/loop)

---

Source: https://learn.benibix.com/term/development/map-filter-reduce
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-17
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
