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;
Enter fullscreen mode Exit fullscreen mode

Example

Support

Current support is all major browsers except IE.

Further reading:

nullish coalescing operator
caniuse
logical OR operator

Top comments (0)