MediumModern JS💻 Output Question

Logical assignment operators

💡

Hint

??= assigns only if null/undefined. ||= if falsy. &&= only if truthy. They short-circuit.

What does this output?

let a = null;
let b = 0;
let c = 'existing';
a ??= 'default';
b ||= 'fallback';
c &&= 'updated';
console.log(a);
console.log(b);
console.log(c);

Correct Output

default
fallback
updated

Why this output?

Explanation: a??=: null, so assign. b||=: 0 is falsy, so assign. c&&=: truthy, so assign.

Key Insight: ??= assigns only if null/undefined. ||= if falsy. &&= only if truthy. They short-circuit.

More Modern JS Output Questions

EasyDestructuring defaults apply only for undefinedEasyObject spread — later properties winMediumOptional chaining prevents TypeError on missing propertiesMediumNullish coalescing ?? vs OR ||

Practice predicting output live →

66 output questions with instant feedback

💻 Try Output Quiz