Ctrl K
Frontend · Junior · Theory

Explain 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?

~4 min by voice

How to approach it

This checks whether the candidate understands JavaScript's execution model: one thread, the call stack, the role of the environment (Web APIs), the difference between macrotasks and microtasks, and whether they can use that to predict the output order confidently rather than guess.

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? JuniorExplain how prototypal inheritance works in JavaScript, and what actually happens when you write a class with extends. Mid-levelImagine 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? Mid-levelWhat is a closure in JavaScript? Give an example of where it's used in practice. JuniorWhat is a promise, and how does async/await differ from a then chain? Junior

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