JavaScript is a dynamic, prototype-based programming language standardized as ECMAScript and used across browsers, servers (Node.js), and embedded runtimes. This cheat sheet covers the most-used language constructs, standard library APIs, and core Web/Node primitives β from everyday ES2015+ syntax through the newest ES2025/2026 features such as Iterator helpers, Set methods, explicit resource management, RegExp.escape, and Promise.try. Examples are intentionally minimal and runnable, emphasizing correct modern syntax, predictable semantics, and common pitfalls. Use the links in the first column as the source of truth for behavior, edge cases, and compatibility.
What This Cheat Sheet Covers
This topic spans 16 focused tables and 241 indexed concepts, 183 flashcards, 5 practice tests with 269 questions. Below is a complete table-by-table outline of this topic, spanning foundational concepts through advanced details.
A jump-to index of every table row in this cheat sheet.
An interactive map of every table and concept in this topic.
Table 1: Core Types & Equality
Every JavaScript value is one of eight primitive types or an Object. Knowing how primitives differ from reference types, how the three comparison algorithms (==, ===, and Object.is) treat NaN and -0, and why typeof null lies prevents a whole class of subtle bugs.
| Type | Example | Description | |
|---|---|---|---|
typeof "hello" β "string" | β’ Returns a string naming the primitive type β’ typeof null === "object" is a legacy bug | ||
0.1 + 0.2 !== 0.3 | β’ IEEE-754 64-bit floating point β’ all integers β€ 2^53β1 are exact | ||
9007199254740992n + 1n | β’ Arbitrary-precision integers β’ append nβ’ cannot mix with Number in arithmetic without explicit conversion (throws TypeError) | ||
"cafΓ©".length β 4 | β’ Immutable UTF-16 code-unit sequence β’ .length counts code units, so an emoji or surrogate pair counts as 2; use [...str] to count characters | ||
Boolean(0) β false | β’ Only false, 0, -0, 0n, "", null, undefined, NaN are falsyβ’ every object (even []) is truthy | ||
let x = null | β’ Intentional absence of value β’ typeof null is "object" (legacy spec error). | ||
let y; y === undefined | β’ Uninitialized variable or missing property β’ null == undefined is true, null === undefined is false. | ||
Symbol("id") !== Symbol("id") | β’ Always unique primitive β’ used for metaprogramming hooks and collision-free property keys | ||
typeof {} === "object" | β’ All non-primitives (arrays, functions, maps, β¦) are objects β’ assigned and compared by reference. | ||
1 === "1" β false | β’ Type-safe equality, no coercion β’ prefer over == to avoid coercion surprises | ||
Object.is(NaN, NaN) β true | β’ SameValue equality β’ treats NaN as equal and -0 as distinct from +0, two cases === handles differently | ||
Number.isNaN(NaN) β true | β’ Safer than global isNaNβ’ no coercion, so returns true only for the actual NaN value | ||
Number.isFinite(Infinity) β false | β’ Safer than global isFiniteβ’ rejects Infinity, -Infinity, and NaN, and non-numbers, without coercion | ||
Number.isInteger(1.0) β true | β’ Returns true for a finite integer value (including 1.0, since JS has no separate integer type)β’ no coercion | ||
Number.isSafeInteger(2**53) β false | β’ Safe range is -(2^53β1) to 2^53β1β’ outside it, distinct integers collapse onto the same double. |