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 →
Also covered in
- .NET in Action, Second Edition
- Pro ASP.NET Core 7, Tenth Edition
- The Art of Code
- Vanilla WebIn early access (MEAP)
- Modern Angular
- Math for Web Design
- JavaScript in DepthIn early access (MEAP)
What to know first
- missing valueA missing value is an expected data value or observation that is absent, unavailable, unknown, or inapplicable.
- undefinedIn JavaScript, undefined is a primitive value that indicates a value is missing, unassigned, or unavailable.
Related concepts
- logical ORcontrasts with · Logical OR is a Boolean disjunction that is true when at least one of its component propositions is true.
- missing valueuses · A missing value is an expected data value or observation that 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.
- operatorkind of · An operator is a symbol, keyword, or language construct that specifies an operation on one or more operands.
- truthinesscontrasts with · Truthiness is a programming language’s rule for interpreting values as true or false in a Boolean context.
Questions about nullish coalescing operator
What is 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.
Which Manning books explain nullish coalescing operator?
Pro Angular 16, Essential TypeScript 5, Third Edition and Kotlin in Action, 2E.
What should I know before learning nullish coalescing operator?
Manning books that teach nullish coalescing operator usually introduce missing value and undefined first.
What is the difference between nullish coalescing operator and logical OR?
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. Logical OR is a Boolean disjunction that is true when at least one of its component propositions is true.
What is nullish coalescing operator a kind of?
Nullish coalescing operator is a kind of null operator. The null-conditional operator conditionally accesses a member or element when its receiver is non-null and otherwise produces null.
What is nullish coalescing operator also called?
Nullish coalescing operator is also called null-coalescing operator.
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.


