Nullish coalescing Operator S4
- Stage: Stage 4
- Status: Finished
- ECMAScript edition: ES2020
- Synchronized: Aug 28, 2026
- 中文译文 · Source repository
The proposal introduces the nullish coalescing operator (?) to provide a default value when a property access yields null or undefined, avoiding unintended behavior with falsy values like 0, '', or false.
The README below comes from the upstream repository and may contain outdated stage or status metadata. Use the proposal details above as the current source of truth.
Nullish Coalescing for JavaScript
Status
Current Stage:
- Stage 4
Authors
- Gabriel Isenberg (github, twitter)
- Daniel Ehrenberg (github, twitter)
- Daniel Rosenwasser (github, twitter)
Overview and motivation
When performing property accesses, it is often desired to provide a default value if the result of that property access is null or undefined. At present, a typical way to express this intent in JavaScript is by using the || operator.
This works well for the common case of null and undefined values, but there are a number of falsy values that might produce surprising results:
The nullary coalescing operator is intended to handle these cases better and serves as an equality check against nullary values (null or undefined).
Syntax
Base case. If the expression at the left-hand side of the ?? operator evaluates to undefined or null, its right-hand side is returned.
Notes
While this proposal specifically calls out null and undefined values, the intent is to provide a complementary operator to the optional chaining operator. This proposal will update to match the semantics of that operator.