Question 20
Back to Exercise
What does the following JavaScript code print (console output, as in Node.js)?
const { theme = "light", lang = "en", fontSize = 16 } = { theme: null, fontSize: 0 };
console.log(theme, lang, fontSize);
- A light en 16
- B null en 0 Correct
- C light en 0
- D null en 16
Correct Answer: Option B
Only lang is missing (undefined), so only lang uses its default. null and 0 are real values. Use ?? after destructuring if null should fall back too.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!