JavaScript Essentials: Understanding ?? vs || Operators
Briefly

The || operator checks for falsy values such as 0, false, NaN, "", null, or undefined, returning the default value on the right when a falsy value is found.
The ?? operator is specific to null and undefined; if the left operand holds a falsy value like 0 or an empty string, it returns the original value.
Use || when you want to catch all falsy values and return a fallback. Use ?? when preserving non-nullish falsy values is necessary.
The performance difference between || and ?? is minor, but their operational differences are significant, guiding developers in choosing the right tool for their intent.
Read at jsdevspace.substack.com
[
|
]