Nullish Coalescing Operator??

The || (OR) operator 

The || (OR) operator will return the right operand if the left operand is falsy (false, 0, empty string, null, undefined, NaN).

When to use?

Use || when you want to provide a fallback for any "falsy" value.

?? (Nullish Coalescing) operator

The ?? (Nullish Coalescing) operator will only return the right operand if the left operand is null or undefined.

When to use?

Use ?? when you want to provide a default value for null or undefined, but consider 0 and empty strings to be valid values.

Example

Popular posts from this blog

What really is a Hypertext?

Browser Rendering Phase

Crypto crypto everywhere but not a token to bet your life on