jsverse
Fundamentals / Arrays

Arrays: map, filter, reduce

Transform, select, and combine — without writing manual loops.

`map` produces a new array by transforming every element. `filter` produces a new array keeping only elements that pass a test. `reduce` collapses an array down to a single value by carrying an accumulator through each element. All three leave the original array untouched.

Codeeditable — Run and Step both follow your edits
Loading...
Console
Output will appear here
Visualization
Element by Element
Step through to watch each element get processed
Why?

map calls your function once per element and collects the return values into a brand-new array — the original array is never mutated.