why keep a JS cheat sheet
JavaScript has been accumulating syntax for 30 years. The core of it is small, but the surface area you're expected to know keeps growing. Array methods alone are a maze: map, filter, reduce, flatMap, findIndex, some, every, and they all do different things, and it's easy to reach for the wrong one. Then there's async, which has gone through three patterns (callbacks to Promise chains to async/await) and the old ones never went away.
You don't forget the language. You forget which method returns a new array and which mutates in place. A reference sheet handles that.
what you'll look up
Array methods are the most common source of confusion. splice mutates the original array. slice returns a copy. If you're doing something functional and you mutate when you meant to copy, you'll spend 20 minutes debugging the wrong thing.
const nums = [1, 2, 3, 4, 5];
// slice: returns a copy, original unchanged
const first3 = nums.slice(0, 3); // [1, 2, 3]
// splice: mutates in place, returns removed elements
const removed = nums.splice(0, 2); // nums is now [3, 4, 5]
Async error handling is the other one. async/await looks synchronous, which makes it easy to forget you still need to catch errors. A rejected promise inside an async function swallows without a trace if you don't wrap it.
// no try/catch: unhandled rejection in some environments
async function fetchData(url) {
const res = await fetch(url);
return res.json();
}
// with error handling
async function fetchData(url) {
try {
const res = await fetch(url);
if (!res.ok) throw new Error(`HTTP ${res.status}`);
return res.json();
} catch (err) {
console.error("fetch failed:", err.message);
return null;
}
}
The second version is only six lines longer, but it's the difference between a failure you can find and one you can't.
get the reference sheet
The JavaScript cheat sheet has array methods, string methods, DOM manipulation, event handling, fetch, and async patterns. One page, printable. PDF and Markdown both available.