In this tutorial, we will explore the nullish coalescing operator, and learn how to use it in our code.
Nullish Coalescing Operator (
The nullish coalescing operator returns the right-hand side operand when the left-hand side operand is
undefined. Otherwise, it returns the left-hand side operand.
const a = null;
const b = 'Hello, world!';
const result = a ?? b;
console.log(result); // Output: 'Hello, world!'