Mar 28, 2023
Great article and explanation! ๐
However, It would also be good to know about the difference between ?? and ||.
Explanation:
The OR operator uses the right value if the left is "falsy", whereas nullish coalesce uses the right value if the left is "null" or "undefined"
So, the OR operator might be problematic if the left value contains an empty string (" ") or zero number. In those cases, it would be useful to use "??".
Example:
0 || "not found" ===> "not found"
0 ?? "not found" ===> "0"