Do you know what will be the output of this code?
JavaScript
console.log(0 ?? 5, 0 || 5);
Show answer and explanation
The answer is 0 5.
?? (nullish coalescing) only uses the right side when the left is null or undefined. || uses it for any falsy value, so 0 is replaced. Use ?? for defaults where 0 or "" are valid.