Question 2
Back to Exercise
JavaScript refuses to run the code below. Which statement correctly describes the problem?
const wait = (ms) => new Promise((r) => setTimeout(r, ms));
queueMicrotask(async => {
await wait(10);
console.log("done");
});
- A It logs done after 10 ms
- B SyntaxError: async => { … } is a normal arrow with a parameter named async, so await inside it is invalid – write async () => { … } Correct
- C queueMicrotask cannot take arrow functions
- D TypeError at run time
Correct Answer: Option B
async is only a keyword when it comes before a parameter list or function; on its own it is a valid identifier.
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!