Array methods you reach for
`map` transforms, `filter` narrows, `reduce` folds. All three return new values — none of them mutate. `sort` and `reverse` DO mutate, so copy first with `toSorted` or a spread.
#array#map#filter#reduce
javascript
const users = [{ name: "Ada", age: 36 }, { name: "Linus", age: 54 }];
const names = users.map((u) => u.name);
const adults = users.filter((u) => u.age >= 18);
const total = users.reduce((sum, u) => sum + u.age, 0);
const found = users.find((u) => u.name === "Ada");
const anyOver50 = users.some((u) => u.age > 50);
const allAdults = users.every((u) => u.age >= 18);
// non-mutating sort
const byAge = [...users].sort((a, b) => a.age - b.age);Related
fetch JSON with error handling
`fetch` only rejects on network failure — a 404 or 500 still resolves. Always check `res.ok` yourself.
Promises and async patterns
Run independent work in parallel with `Promise.all`. Use `allSettled` when one failure shouldn't kill the batch, and `race`/`AbortController` for timeouts.