ES6 (ECMAScript 2015) is the baseline of modern JavaScript: let/const, arrows, classes, template literals, destructuring, default parameters, and import/export. Later yearly editions added async/await, optional chaining, and nullish coalescing — this sheet groups the syntax you type every day.
This JavaScript cheat sheet is written for people searching for a fast, accurate reference: students, junior developers, and teams shipping production software. Pin it, copy the snippets, and come back when syntax slips.
Quick reference
- let / const:
constby default.letwhen the binding is reassigned. Block scoped. Skipvar. - Arrow:
(x) => x * 2lexically bindsthis. Not constructable, noargumentsobject. - Destructure:
const {title, slug} = postandconst [first, ...rest] = rows. - Default:
function greet(name = "there"). - Spread:
{...a, ...b}and[...items, next]. Later keys win on objects. - Rest:
function f(a, ...rest)gathers remaining args into an array. - Module:
export function x(){}/import {x} from "./x.js"withtype="module". - Optional:
user?.cityandvalue ?? "n/a"(null or undefined only).
Copy-paste examples
Destructure, spread, and a module-style helper
Nullish ?? does not treat 0 or "" as missing. Optional chaining stops at the first nullish.
export function invoiceLabel({ id, total, paid = false }) {
const status = paid ? 'paid' : 'due';
return `#${id} · ${total ?? 0} · ${status}`;
}
const defaults = { currency: 'USD', paid: false };
const row = { ...defaults, id: 41, total: 99 };
const { currency, ...data } = row;Common mistakes
- Using arrows for object methods that need
this(it will be lexical, oftenundefinedin modules). constobjects are mutable — only the binding is constant. Freeze if you need that.- Mixing
importandrequirein the same file without a bundler strategy. - Default parameters evaluating
{}once incorrectly — defaults run per call, but shared object literals as defaults are a trap if you mutate them.
FAQ
- Is ES6 supported in browsers? Yes for current evergreen browsers. You transpile only if you must support very old environments.
- var vs let?
varis function-scoped and hoisted asundefined.letis block-scoped and in the temporal dead zone until initialized.
- Do I need classes? Optional. Classes are syntax over prototypes. Functions plus closures are still valid.
Related JavaScript cheat sheets
- Javascript Cheat Sheet 2026
- Javascript Array Methods Cheat Sheet
- Javascript String Methods Cheat Sheet
Build with this stack
When a cheat sheet is not enough — you need a production app, a student FYP, or a custom dashboard — ArpaNeuro builds custom web development and also sells ready-made source code. Request a quote and tell us the stack.
Browse software development services or the source code marketplace if you want a working codebase instead of starting from a blank file.