Skip to content

Latest commit

 

History

History
19 lines (11 loc) · 541 Bytes

what_is_nullish_coalescing_operator_.md

File metadata and controls

19 lines (11 loc) · 541 Bytes

What is nullish coalescing operator (??)?

The ?? operator returns the right-hand operand if the left-hand operand is null or undefined. It is useful for providing default values.

Example:

const value = null;
console.log(value ?? 'default'); // Output: 'default'

const number = 0;
console.log(number ?? 42); // Output: 0

Tags: basic, JavaScript, Operators