ES6+ Cheatsheet - ES6+ JavaScript Syntax Reference
This reference is for JavaScript developers who want to write modern code instead of callback-and-var-era patterns, covering the ES2015+ features that reshaped daily use: let/const block scoping, arrow functions, destructuring, template literals, Promise/async flow, import/export modules, classes, Map/Set, and iterators. Unlike a dry spec list, entries are grouped by the situation each feature fixes — scope confusion, unwieldy callbacks, or verbose object access. After reading you should be able to replace var with block-scoped bindings, flatten nested callbacks with async/await, and structure multi-file projects with import/export.
Variables & Functions 9
let x = 1const PI = 3.14const fn = (x) => x * 2const fn = (x, y = 1) => x + yconst fn = (...args) => argsfn(...[1, 2, 3])user?.namevalue ?? "default"`Hello ${name}`Destructuring 5
const [a, b] = [1, 2]const { name, age } = userconst { name: userName } = userconst [a, ...rest] = [1, 2, 3]function fn({ name, age = 18 }) {}Asynchronous 8
new Promise((resolve, reject) => {})promise.then().catch().finally()Promise.all([p1, p2])Promise.race([p1, p2])async function fn() { await promise }try { await fn() } catch (e) {}Promise.allSettled([p1, p2])Promise.any([p1, p2])Modules 6
export const fn = () => {}export default fnimport { fn } from "./module"import fn from "./module"import * as mod from "./module"import("./module").then(mod => {})Classes & Data Structures 8
class User { constructor() {} }class Admin extends User {}const map = new Map()const set = new Set([1, 2, 3])for (const [k, v] of map) {}Array.from(set)Symbol("id")for (const item of iterable) {}Proxy/Reflect & Generators 8
new Proxy(target, handler)handler.get(target, key, receiver)handler.set(target, key, value)Reflect.get(obj, key)function* gen() { yield 1; yield 2; }const it = gen(); it.next(); it.next()for (const v of gen()) {}const wm = new WeakMap()Tips
- const objects/arrays are still mutable inside; only the reference is immutable.
- Arrow functions have no this of their own; they inherit the enclosing scope.
- async/await is syntactic sugar over Promises; catch errors with try/catch.
- ?. and ?? are ES2020: ?. short-circuits to undefined, ?? triggers only on null/undefined.
- Proxy is commonly used for reactivity (e.g. Vue 3 reactive); Reflect forwards the matching default behavior.
- A generator pauses at yield and returns a value; calling next() resumes execution.
- WeakMap/WeakSet keys are weak references and don't block GC - good for caches.
Official References
Each command links to its official documentation below, so you can verify the latest usage and read deeper.
Maintained by LaoHand
Publicly updated on Jul 21, 2026, continuously proofread against official docs.
Contact Us
Wrong command or description? Send us corrections, business inquiries or product feedback by email.
Contact Us