FOR JAVASCRIPT EDUCATORS
What runs now?
What waits?
Turn three short snippets into a classroom conversation about synchronous code, Promise microtasks and timer tasks. Predict first. Compare reasoning. Trace the queues together.
A READY-TO-USE CLASSROOM ACTIVITY
One activity. On screen or paper.
- Predict independently. Ask learners to write each log in order without running the code.
- Compare explanations. Which callbacks are only registered? Which queue is waiting at the end of the script?
- Reveal and trace. Use the separate teacher key or check a prediction in the embedded tool. Discuss why a nested microtask waits behind one already queued, and why a Promise inside a timer cannot run before that timer starts.
Choose your sheet, then print or save as PDF. A4 or Letter, portrait; one snippet per page with writing space. The learner sheet has no answers. The teacher key is a separate public page, not a private access gate. Keep it for explanation time.
Treat each snippet as an independent, isolated browser script. Every Promise.resolve() here is already fulfilled and each snippet has one timer. Predict output order, not elapsed time: a requested 0 ms delay is not an exact execution time. This activity does not model unrelated browser work or every event-loop phase. A pending Promise’s handler waits for settlement; Promises do not always “beat” timers.
These are the tool’s three existing free teaching examples, not new topics or paid-pack content. No signup required.
Copy. Paste. Let them predict.
Paste this into a custom HTML or iframe block on your course page. Your platform must allow iframes from https://codepeek.brainer.one.
It fills its container’s width. The 780px height keeps setup script-free; longer answers scroll inside the frame. You can adjust the height to fit your lesson. No learner account is required. Predictions stay in page memory and are not sent as puzzle-usage events. The embedded page still uses Brainer website-visit analytics and Cloudflare performance measurement, independently of puzzle-count permission. Privacy & data ↗. Refreshing starts a fresh activity; main-app progress stays separate.
If your platform blocks embeds, print the learner handout or link to the free challenge instead ↗. Questions? codepeek@brainer.one
LIVE EXAMPLE
Pause the lesson. Predict the queue.
Choose one of the three snippets, predict the log order, then check and step through. Queue state and explanation stay hidden until a prediction is submitted.
This is the same iframe your learners will use, not a screenshot. CodePeek’s practice links open in a new tab.
Put the model to work
Continue with The tiny queue, Zero is not now, or Pause, not stop. All are in the 15 free starter puzzles; guest play needs no account.
Background reading: MDN’s microtask guide and timer delay caveats.
