Array Methods: map filter reduce find
Transform, filter, and aggregate arrays with higher-order methods instead of manual loops. Chain them for expressive data pipelines.
Why Array Methods?
Imperative for loops work but hide intent. Array higher-order methods declare what you want rather than how to iterate. They produce cleaner, testable, composable code that reads like prose.
Array.map() — Transform Every Element
map() returns a new array where every element has been transformed by the callback. The original array is not mutated. Use it whenever you need to convert one array to another.
const names = ['alice', 'bob', 'carol'];
const upper = names.map(name => name.toUpperCase());
// ['ALICE', 'BOB', 'CAROL']
const prices = [10, 20, 30];
const withTax = prices.map(p => p * 1.2);
// [12, 24, 36]All lessons in this course
- Array Methods: map filter reduce find
- Object Destructuring and Spread
- Template Literals and Optional Chaining
- Modules: import and export