Skip to main content

Interview preparation

JavaScript Interview Questions with Practical Answers

Practice accurate runtime models and connect every answer to observable behavior, trade-offs, and a small executable example.

JavaScriptintermediate4 min readWeb interviews

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.

event-loop.js
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.

  1. JavaScript
  2. Web interviews
  3. javascript
  4. interviews
  5. closures
  6. async
  7. What Is JavaScript in Programming?
  8. Learn JavaScript: From Fundamentals to Web Applications
  9. JavaScript Tutorial: Build a Filterable Task List

Recommended automatically from shared technologies, topics, intent, and difficulty.

Hand-picked companion pages that deepen this topic.

Your next steps

Continue learning

  1. 1glossaryWhat Is JavaScript in Programming?
  2. 2guidesLearn JavaScript: From Fundamentals to Web Applications
  3. 3guidesJavaScript Tutorial: Build a Filterable Task List
  4. 4cheatsheetsJavaScript Cheatsheet: Syntax, Collections, DOM, Async