Languages · INTERVIEW GUIDE
Practice this topicJavaScript & TypeScript
Scope, closures, async behavior, object identity, and the type system.
Scope & execution7Functions & objects5Async JavaScript4Runtime & modules3TypeScript6Output prediction2
2 questions
What is the output here?
Output prediction requires following the order in which synchronous code and queued callbacks can execute. This example combines the current script, a promise microtask and a timer callback. A zero-delay timer becomes eligible later; it does not interrupt the running script.
Intermediate2 min read
Why does a var loop print 3 three times?
The var loop creates one shared function-scoped binding for i. Every callback closes over that same binding, and the loop has already set it to 3 before the timer callbacks run. Using let in the loop header creates a separate binding for each iteration.
Intermediate2 min read
Difficulty is an editorial estimate. Completion means you chose to mark a question as understood.