Learning overview
- Estimated time
- 4 minutes
- Difficulty
- Intermediate
- Prerequisites
- Learn JavaScript: From Fundamentals to Web Applications · JavaScript Cheatsheet: Syntax, Collections, DOM, Async
- Learning outcome
- Explain javascript using a clear mental model · Apply javascript in practical JavaScript work
- Last updated
- July 18, 2026
Core answer
Let and const are block-scoped and exist in a temporal dead zone before initialization. Const prevents reassignment of the binding; it does not make an object deeply immutable. Var is function-scoped and its declaration is hoisted with an initial value of undefined.
A closure is a function together with access to its lexical environment. It allows callbacks and returned functions to retain variables from their creation scope, which supports encapsulation but can also keep referenced data alive.
JavaScript executes synchronous work on a call stack. Promise reactions enter the microtask queue, while timers generally schedule tasks. After the current stack finishes, microtasks drain before the next task, which explains common ordering questions.
Worked example
Predict the output by separating synchronous stack execution, promise microtasks, and timer tasks.
console.log("A");
setTimeout(() => console.log("B"), 0);
Promise.resolve().then(() => console.log("C"));
console.log("D");Output
A D C B
Follow-up questions
Strong interviews test whether you can apply the idea, not only recite a definition. Practice answering these out loud.
- How do strict equality and Object.is differ?
- What is the difference between null and undefined?
- When does this depend on the call site?
- How do map, filter, and reduce differ?
- What is prototype delegation?
- What is the difference between shallow and deep copying?
- How do Promise.all and Promise.allSettled differ?
- How do you cancel a fetch request?
- What causes a memory leak in browser JavaScript?
- How would you avoid cross-site scripting when rendering data?
Frequently asked questions
How should I prepare for JavaScript interviews?
Predict small programs, explain the runtime model aloud, verify results, and practice applying fundamentals to DOM, data, asynchronous, and debugging scenarios.
Should I memorize event-loop output questions?
No. Learn the call stack, microtask queue, and task queue model so you can derive unfamiliar examples accurately.
Topic graph
A taxonomy-generated path through this subject.
Related courses
Related learning
Recommended automatically from shared technologies, topics, intent, and difficulty.
Related Guides
Related Tutorials
Related Glossary
Related Cheatsheets
Related Projects
Related Interview Questions
Related reading
Hand-picked companion pages that deepen this topic.
Your next steps
