Explain why asynchronous callbacks run later.
- call stack
- microtasks
- tasks
- rendering
Synchronous code runs on the call stack. Promise reactions run as microtasks after current synchronous work; timers queue tasks for later turns. Rendering happens between suitable turns, so blocking work can delay both callbacks and paint. Predicting order helps debug surprising output.
A zero-millisecond timeout does not interrupt currently running JavaScript.
Predict the order of logs from synchronous statements, a resolved promise, and a timeout.
Open example.html in a browser and edit example.js. Save, refresh, and use the Console and debugger to inspect values.
- Explain the core idea in your own words without reading the code.
- Change one input and predict the output before running it.
- Test one boundary or failure case, then record what you changed.