`??` as a "fallback when undefined" operator
c-smile opened this issue · comments
??
operator has a value by its own.
It can be treated as "fallback when exactly undefined" operator - close to ||
but for exactly undefined values.
Consider the following:
var zero = 0;
var none; // undefined
zero || 1 == 1;
zero ?? 1 == 0; // this is the difference from ||
none || 1 == 1;
none ?? 1 == 1; // for exactly undefined || and ?? behave the same
??
operator has a value by its own.
Of course, but it’s not the business of this proposal (Optional chaining, ?.
) to discuss the own value of Nullish coalescing (??
), which is a different proposal. For that, see rather: https://github.com/tc39/proposal-nullish-coalescing.
Closing as off-topic.