Back to questions
JuniorTheoryCommon
What does the program print?
const n = 0;
console.log(n || 10, n ?? 10);10 0
- Expecting
??to replace0as well:??reacts only tonullandundefined, and0is neither, son ?? 10gives0. - Expecting
||to keep0:||returns its right side whenever the left side is falsy, and0is falsy, son || 10gives10.
- What does the program print if
nisnullinstead of0? - Which of the two operators would you use for a default count that may legitimately be
0?