Ctrl K
Frontend · Mid-level · Theory

Imagine your code has, one after another, a console.log, a setTimeout with zero delay, a Promise.resolve().then and an async function with an await. In what order will these run, and why?

~4 min by voice

How to approach it

The interviewer wants to see whether you understand the event loop model: the synchronous stack, the macrotask and microtask queues, their priority, and the fact that async/await is built on top of promises. It's not enough to name the order; you need to explain it and show where it affects real code.

Have you seen this question in a real interview?
Answers0
Avg. score—
Strong—
Practiced0
Topics
Similar questionsExplain how async and await work in Python. What happens if you call a regular time.sleep inside a coroutine? JuniorYou need to load data for a hundred IDs, but the backend can handle no more than three parallel requests. How would you implement this, and how would you handle errors in individual requests? Mid-levelExplain how the event loop works in JavaScript. And what gets printed to the console if a script has, one after another, a console.log, a setTimeout with zero delay, and a Promise.resolve().then? JuniorWalk me through how the event loop works in the browser and where frame rendering fits into it. How has this knowledge helped you in practice? Senior

Answer by voice

The interviewer will ask this question and listen. Think out loud and ask for a hint if you need one. When you're done, pause or tap “That's my answer”. In about a minute, your score and the points you covered show up here.

Sign in to answer

Best with headphones · ~4 min