JavaScript
Array methods, fetch, promises, and browser storage.
Array methods you reach for
arraymapfilter`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.
fetch JSON with error handling
fetchasynchttp`fetch` only rejects on network failure — a 404 or 500 still resolves. Always check `res.ok` yourself.
Promises and async patterns
promiseasyncawaitRun independent work in parallel with `Promise.all`. Use `allSettled` when one failure shouldn't kill the batch, and `race`/`AbortController` for timeouts.
localStorage without the footguns
storagebrowserjsonlocalStorage stores strings only, is synchronous, and throws in private mode or when full. Wrap reads in try/catch and never touch it during server rendering.
Debounce and throttle
performanceeventstimersDebounce waits until the noise stops (search inputs). Throttle guarantees a steady rate (scroll, resize).