Nullish Coalescing
Definition
The `??` operator that returns the right-hand operand when the left-hand operand is `null` or `undefined`. Unlike `||`, it does not treat `0`, `''`, or `false` as nullish, making it safer for default values.
Code Example
Javascript
Tip: Modify the code above and click “Run” to see the results
Learn More
Related Terms
Truthy and Falsy
In JavaScript, every value is either truthy or falsy when evaluated in a boolean context. Falsy values are: false, 0, '', null, undefined, NaN, and 0n. Everything else is truthy, including empty arrays and objects.
Optional ChainingThe ?. operator that safely accesses deeply nested object properties without throwing if an intermediate value is null or undefined. Returns undefined instead of throwing a TypeError.