Mastering default values in JavaScript with the nullish coalescing (??) operator - Matt Smith
Briefly

The nullish coalescing (??) operator in JavaScript provides a more accurate way to handle default values than the logical OR (||) operator. While || treats several values as falsy (including false, 0, NaN, and empty strings), ?? only recognizes null and undefined as falsy. This means that using ?? allows developers to preserve useful falsy values, making code more predictable and reliable by avoiding unintended replacements. This distinction is vital when dealing with numbers or empty strings, ensuring accurate handling of default values.
The nullish coalescing operator (??) handles default values without altering falsy values such as 0, thus preventing unintended consequences when coding.
Unlike the logical OR (||), which returns the right-hand operand for any falsy left-hand operand, the ?? operator only considers null and undefined as falsy.
Read at Allthingssmitty
[
|
]