Operators

Nullish coalescing (??)

Try the free JavaScript compiler

Returns the left operand except when it is null or undefined, in which case it evaluates the right. Mixing directly with && or || without grouping is invalid syntax.

Formal Syntax & Structure

javascript syntaxjavascript
left ?? right

Parameters & Attributes

NameTypeDescription
leftexpressionLeft operand.
rightexpressionRight operand; short-circuiting may skip evaluation where applicable.

Return Value

operand value

Result of the operation.

Working Example

Example Snippetjavascript
console.log(0 ?? 7);
JavaScript Reference