🦺 Nullish Coalescing

How nullish coalescing is realted to truthy and falsy values

Which one of these values is truthy?

Nullish Coalescing

Nullish coalescing is a relativly new operator that was introduced in ES2020. It is similar to the logical OR operator ||, but it only returns the right-hand side if the left-hand side is null or undefined.

const foo = null ?? 'bar';
console.log(foo); // 'bar'

const foo = 0 ?? 'bar';
console.log(foo); // 0

Questions? Let's chat

Open Discord