In this blog we are going to learn about Nullish coalescing operator denoted by (??) and how it is different from OR operator.
Nullish Coalescing :- It is a logical operator that returns its right-hand side operand when its left-hand side operand is null or undefined, and otherwise returns its left-hand side operand.
How it is different from OR operator?
Any falsy value (0, '', NaN, null, undefined) is not returned in OR operator because OR is a boolean logical operator.
For Example
Where as Nullish coalescing operator avoids this by only returning the second operand when the first one evaluates to either null or undefined (but no other falsy values)
Guess output of this
comment your answer ; )