JavaScript Tutorial: Arrays
JavaScript arrays and their powerful built-in methods: map, filter, reduce, find, and more.
The most-used data structure
Arrays are everywhere in JavaScript — every API response is an array of objects, every list is an array, every data transformation touches arrays.
The modern array methods (`map`, `filter`, `reduce`) are what separate JavaScript developers from JavaScript masters. They let you transform data declaratively — saying WHAT you want, not HOW to do it step by step.
What you'll learn in this JavaScript arrays tutorial
This interactive JavaScript tutorial has 10 hands-on exercises. Estimated time: 22 minutes.
- Arrays — one variable, many values — From Chapter 2: `const name = "Alex"` stores one value. But what if you have 100 names? 100 variables? No.
- push, pop, shift, unshift — Four mutation methods:
- map — transform every item — `.map()` runs a function on every element and returns a **new array** with the transformed values. The original is uncha…
- filter — keep what you want — `.filter()` runs a test function on every element and returns a **new array** containing only the elements that pass.
- reduce — collapse to one value — `reduce` is the most powerful array method — it collapses the whole array into a single value (sum, object, another arra…
- find, findIndex, some, every — Four search/test methods:
- slice — non-mutating extraction — `slice(start, end)` extracts a portion WITHOUT modifying the original:
- spread — copy and merge arrays — The spread operator `...` expands an array into individual elements:
- flat and flatMap — `.flat()` flattens nested arrays one level (or more with a depth argument).
- Build a data pipeline — Final challenge — the real power of array methods is **chaining** them.
JavaScript Arrays concepts covered
- The most-used data structure