??. The left-hand side of the operator is returned as long as the right-hand side is neither
undefined and vice-versa.
const example1 = 'Hello' ?? null //Result: Hello
const example2 = 'Hello' ?? undefined //Result: Hello
const example3 = null ?? 'Hello' //Result: Hello
const example4 = undefined ?? 'Hello' //Result: Hello
The rule above holds true except when you are dealing with a falsy value.
Difference between nullish coalescing and OR (||)
Like nullish coalescing, OR (||) is a logical operator. The difference between them is that logical OR evaluates to true iff (if and only if) “one or more of its operands is true.” When used with Boolean values, a Boolean value is returned. However, when used with non-Boolean values, non-Boolean values are returned.
const a = 1; const b = 2; const c = 3; const d = 4; console.log(a > b || c > d); //(1 > 2 || 3 > 4) Result: false
const b = 2 from the previous example:
const string = ""; console.log(string || b); //Result: 2
 Logical OR (||)