EasyModern JS💻 Output Question

Destructuring defaults apply only for undefined

💡

Hint

Destructuring defaults only trigger on undefined. null, 0, "" all suppress the default.

What does this output?

const { a = 1, b = 2, c = 3 } = { a: 10, b: null };
console.log(a);
console.log(b);
console.log(c);

Correct Output

10
null
3

Why this output?

Explanation: a=10 (provided). b=null — null is not undefined, so default 2 does not apply. c missing → default 3.

Key Insight: Destructuring defaults only trigger on undefined. null, 0, "" all suppress the default.

More Modern JS Output Questions

EasyObject spread — later properties winMediumOptional chaining prevents TypeError on missing propertiesMediumNullish coalescing ?? vs OR ||EasyTemplate literal expressions

Practice predicting output live →

66 output questions with instant feedback

💻 Try Output Quiz