Values and language basics
Syllabus
Detailed content
Values, types, and equality
JavaScript values include primitives such as string, number, bigint, boolean, null, undefined, and symbol, plus objects. typeof has edge cases, and strict equality avoids most coercion surprises. Use explicit conversion at boundaries and distinguish a missing property from a property whose value is undefined.
Variables, scope, and control flow
const prevents rebinding, while let allows it; var has older function-scoped behavior and is usually avoided in modern code. Blocks create lexical scope. Conditionals and loops control execution. Prefer narrow scopes and clear early returns so the state a function can change remains easy to understand.
Arrays, objects, and destructuring
Arrays represent ordered collections; objects map property keys to values. Destructuring extracts fields into local bindings. Spread syntax copies enumerable properties or array elements, but it is shallow: nested objects remain shared. Use immutable update patterns carefully and avoid assuming a copy isolates nested state.