JavaScript

JavaScript Cheat Sheet

Quick reference for ES6+ array methods, async/await, DOM manipulation, promises, and object destruction.

Array Methods

Array.prototype.map()
const doubled = numbers.map(x => x * 2);
Array.prototype.filter()
const evens = numbers.filter(x => x % 2 === 0);
Array.prototype.reduce()
const sum = numbers.reduce((acc, curr) => acc + curr, 0);

Async & Promises

async / await
async function fetchData() { const res = await fetch("/api/data"); const json = await res.json(); return json; }
Promise.all()
const [user, posts] = await Promise.all([getUser(), getPosts()]);