DEV Community

Cover image for Nibbles: nullish coalescing
Andrew Bone
Andrew Bone

Posted on

Nibbles: nullish coalescing

The nullish coalescing operator is a logical operator similar to the logical OR operator. The operator will return what is on it's right hand side when the left hand side is nullish, (null or undefined).

Syntax

const output = leftExpr ?? rightExpr;

Example

Support

Current support is all major browsers except IE.

Further reading:

nullish coalescing operator
caniuse
logical OR operator

Discussion (0)