real trace · browser-js
02. JavaScript runtime / Lesson 2 of 6 · intermediate · 10 min · 10 steps

The event loop

Why the agent's search box shows results out of order.

1-min Short
CONSOLE????CALL STACKemptyEVENT LOOPWEB APISidleMICROTASK QUEUEemptyTASK QUEUEempty

An agent wrote a search box. Type fast, and sometimes the results belong to an older query.

IN THIS LESSONStep 1 of 10 · Symptom0:00 / 1:22

Transcript

follows the lesson · 0 of 10 steps

The event loop: the whole lesson in words

Typing in the search box sometimes shows results for an older query.

The one-page cheatsheet for this lesson →

Sources

order.js · human-writtenjavascript
console.log('A');
setTimeout(() => console.log('B'), 0);
Promise.resolve().then(() => console.log('C'));
console.log('D');
CHEATSHEET

Opens after you lock in your predictions. It states the answers.