Cheat Sheet
The commands you keep forgetting, with a one-line description and a real example you can copy - 629 across 38 tools. Pick a tool in the sidebar, or search across all of them.
JavaScript
The array methods, destructuring, and async patterns you reach for daily.| Command | What it does | Example |
|---|---|---|
.map() | Transform every element into a new array. | prices.map(p => p * 1.2) |
.filter() | Keep only elements that pass the test. | todos.filter(t => !t.done) |
.find() | First element matching, or undefined. | users.find(u => u.id === 7) |
.some() / .every() | Does any / do all pass the test? | items.some(i => i.price > 100) |
.reduce() | Fold an array into one value. | cart.reduce((sum, i) => sum + i.price, 0) |
.includes() | Is this value in the array (or string)? | roles.includes('admin') |
.flat() / .flatMap() | Flatten nested arrays / map then flatten. | orders.flatMap(o => o.items) |
.sort() (copy first!) | Sorts IN PLACE - spread to keep the original. | [...scores].sort((a, b) => a - b) |
.at(-1) | Last element without length math. | history.at(-1) |
destructuring (object) | Pull fields into variables, with defaults. | const { name, role = 'user' } = person |
destructuring (array) | Unpack by position; skip with commas. | const [first, , third] = rows |
spread | Copy/merge arrays and objects immutably. | const next = { ...state, count: 5 } |
rest args | Gather remaining arguments into an array. | function sum(...nums) { return nums.reduce((a, b) => a + b, 0) } |
?. (optional chaining) | Stop safely at null/undefined mid-path. | order?.customer?.email |
?? (nullish coalescing) | Default only for null/undefined (0 and "" pass). | const limit = config.limit ?? 50 |
template literals | Strings with embedded expressions, multiline. | `Hello ${user.name}, ${count} new` |
async / await | Write promise code that reads top-to-bottom. | const res = await fetch(url); const data = await res.json() |
try / catch (async) | Handle a rejected await. | try { await save() } catch (e) { console.error(e) } |
Promise.all | Run promises in parallel, wait for all. | const [user, posts] = await Promise.all([getUser(), getPosts()]) |
JSON.parse / stringify | Text to object and back (pretty-print with 2). | JSON.stringify(data, null, 2) |
Object.entries / keys | Loop an object like an array. | Object.entries(scores).map(([k, v]) => `${k}: ${v}`) |
structuredClone | Real deep copy (unlike spread, which is shallow). | const copy = structuredClone(state) |