3-6y

JavaScript Event Loop and Async Thinking

JavaScript does one main thing at a time on the stack. Finished async work waits in queues. Promise callbacks run before timers after the current stack clears.

Analogy

A teacher finishes the current student first, then checks urgent sticky notes before moving to the next student in line.

Follow-up questions

Topic practice prompts

Why do promise callbacks run before setTimeout callbacks after synchronous code finishes?

Because resolved promise callbacks go into the microtask queue, and microtasks run before the next macrotask like setTimeout.

  • Can too many microtasks hurt responsiveness?
  • What else is a microtask?
Cheat sheet

Last-day revision lines

  • Stack first.
  • Then microtasks.
  • Then next task.
  • Main-thread time is user experience.
Source references
  • Frontend self mock guide: context/Frontend Interview_ Topic-Wise Self Mock Interview Guide.docx
  • JS interview preparation: context/JS Interview Preparation Questions.docx
Offline study support

Local resource packs for this topic

2 local packs

Use these local packs when you want broader official-source context without leaving the app.

javascriptRuntime, closures, and async behavior

JavaScript Runtime and Closures

A local offline guide to the JavaScript runtime ideas interviewers repeatedly use for JS and browser rounds.

JavaScriptBrowser and DOM

Closures, lexical scope, event loop, microtasks, timers, promise ordering, and DOM callback behavior.

Open local study pack
frontendTypeScript for frontend interviews

TypeScript for React Interviews

A local TypeScript interview pack focused on the pieces that improve React answers instead of random language trivia.

Frontend BreadthReact.jsJavaScript

Props typing, unions, narrowing, generics, API models, and writing safer component contracts.

Open local study pack
Next step

Related topics to study after this one

Browser and DOM1-3y

DOM Events and Event Delegation

Cover bubbling, capturing, target vs currentTarget, and scalable event handling.

Simple mode, interview mode, example, pitfalls, and follow-ups are all inside this topic.

domevent-bubblingdelegationbrowser
Study topic
Machine Coding3-6y

Machine Coding Round Approach

Show how to scope, structure, and narrate your work in the practical frontend round.

Simple mode, interview mode, example, pitfalls, and follow-ups are all inside this topic.

machine-codingcomponent-designcommunicationtime-management
Study topic