Nullish coalescing operator
A conditional operator that yields its left operand unless it is null or an equivalent absent value, in which case it yields a fallback right operand.
Pro Angular 16
The nullish coalescing operator returns its right operand only when its left operand is null or undefined.
- How it is used
- Supplies defaults for null or undefined values while preserving zero in TypeScript expressions and Angular class bindings.
- How deep it goes
- Defines the operator through console examples and works through a comparison-precedence pitfall, without examining runtime internals.
- Examples
- Uses browser-console results for undefined, a string, and zero, then applies a missing-price fallback to CSS class selection.
- What you can do after
- Practice/perform it by replacing truthiness-based fallbacks with `??` and parenthesizing coalesced values before comparisons.
Read how Pro Angular 16 explains nullish coalescing operator →
Essential TypeScript 5, Third Edition
The nullish coalescing operator returns its right-hand operand only when its left-hand operand is null or undefined.
- How it is used
- Supplies defaults for missing rates and object properties while preserving valid falsy values.
- How deep it goes
- Explains operand behavior through worked JavaScript expressions and applies it to property access without examining operator internals.
- Examples
- Uses a zero-rated tax calculation, object-price fallbacks, and a missing indexed product.
- What you can do after
- Diagnose/debug with it when logical OR replaces a legitimate zero or an optional property needs a fallback.
Read how Essential TypeScript 5, Third Edition explains nullish coalescing operator →
Kotlin in Action, 2E
The Elvis operator `?:` evaluates its left operand when non-null and otherwise evaluates and returns its right operand.
- How it is used
- Provides defaults or immediate control-flow exits when nullable expressions lack usable values.
- How deep it goes
- Explains evaluation, safe-call combinations, defaults, and throw-based validation through compact Kotlin examples.
- Examples
- Uses nullable string lengths, names, nested company addresses, shipping labels, and missing person ages.
- What you can do after
- Apply it to replace null with defaults or enforce preconditions using return and throw expressions.
Read how Kotlin in Action, 2E explains nullish coalescing operator →
Related concepts
- logical ORcontrasts with · Logical OR is a Boolean disjunction that evaluates to true when at least one operand or condition is true.
- missing valueuses · A missing value is a marker or condition indicating that an expected data value or reference is absent, unavailable, unknown, or inapplicable.
- null operatorkind of · The null-conditional operator conditionally accesses a member or element when its receiver is non-null and otherwise produces null.
- truthinesscontrasts with · Truthiness is a programming language’s rule for interpreting values as true or false in a Boolean context.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.


