Question 7
Back to Exercise
The code below stops with an uncaught error. Which statement correctly describes the problem?
const raw = ""; // the cache file was empty
queueMicrotask(() => {
const settings = JSON.parse(raw);
console.log("theme:", settings.theme);
});
console.log("app ready");
- A It prints theme: undefined
- B It prints app ready only
- C The script is rejected before it runs
- D After "app ready", JSON.parse("") throws a SyntaxError inside the microtask, which nothing catches Correct
Correct Answer: Option D
The code is valid; the parse fails at run time. Errors thrown in queueMicrotask callbacks are reported as uncaught – guard the parse with try/catch.
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!