issue 117apr 27mmxxvi
est. 2026
delhi/ncr edition
vol. IX · no. 117
PapersAdda
placement intelligence, source-anchored
1,000+ briefs · 24 campuses · 120+ companies
verified offers · sourced from r/developersIndia
razorpay₹65.00 LPA· iit-d · sde-1google₹54.00 LPA· iiit-h · swe-imicrosoft₹49.50 LPA· iit-b · sdeatlassian₹38.00 LPA· nit-w · sde-1amazon₹44.20 LPA· bits-p · sde-1uber₹42.00 LPA· iit-kgp · sde-1razorpay₹65.00 LPA· iit-d · sde-1google₹54.00 LPA· iiit-h · swe-imicrosoft₹49.50 LPA· iit-b · sdeatlassian₹38.00 LPA· nit-w · sde-1amazon₹44.20 LPA· bits-p · sde-1uber₹42.00 LPA· iit-kgp · sde-1
section: Interview Questions / interview questions
08 Jun 2026
placement brief / Interview Questions / interview questions / 08 Jun 2026

JavaScript Closures Interview Questions 2026: 26 Q&A

26 JavaScript closures interview questions for 2026 with full answers, lexical scope, the loop closure bug, currying, memoization and predict-the-output snippets. Candidate-reported frontend and full-stack favourites.

on this page§ 09
advertisement

Last Updated: June 2026 | Level: Freshers to Mid-Level | Read Time: ~15 min

Closures are the concept that most distinguishes confident JavaScript developers in interviews. Candidates report that the definition, the loop closure bug, and practical uses like the module pattern and currying are guaranteed questions. This guide covers 26 closure questions with full answers, runnable code, and predict-the-output traps. Behaviour reflects the official MDN documentation; confirm any scope detail on MDN.

Pair this with JavaScript Interview Questions for Freshers 2026 and JavaScript Output Questions 2026.


Table of Contents

  1. Fundamentals (Q1 to Q9)
  2. The Loop Bug and Scope (Q10 to Q16)
  3. Practical Patterns (Q17 to Q23)
  4. Advanced (Q24 to Q26)
  5. Predict the Output
  6. Quick Revision Table
  7. Frequently Asked Questions

Fundamentals

Q1. What is a closure? Easy

function outer() {
  let count = 0;
  return function() { return ++count; };
}
const inc = outer();
inc(); inc();   // 1, then 2

Q2. What is lexical scope? Easy


Q3. How does a closure keep a variable alive? Medium


Q4. What is the difference between scope and closure? Medium


Q5. Can closures cause memory leaks? Hard


Q6. Do closures capture by value or by reference? Hard


Q7. What is an IIFE and how does it relate to closures? Medium

(function() { /* private scope */ })();

Q8. Can a closure modify the captured variable? Easy


Q9. How many closures are created in a function with two inner functions? Hard


The Loop Bug and Scope

Q10. What is the classic closure-in-a-loop bug? Medium

for (var i = 0; i < 3; i++) setTimeout(() => console.log(i)); // 3 3 3
for (let i = 0; i < 3; i++) setTimeout(() => console.log(i)); // 0 1 2

Q11. How does let fix the loop bug? Medium


Q12. How would you fix the loop bug without let? Hard

for (var i = 0; i < 3; i++) {
  (function(j) { setTimeout(() => console.log(j)); })(i);
}

Q13. What is variable shadowing? Medium


Q14. What is the temporal dead zone? Hard


Q15. Do closures work with block scope? Medium


Q16. What does this snippet print and why? Medium


Practical Patterns

Q17. What is the module pattern? Medium

const counter = (function() {
  let c = 0;
  return { inc: () => ++c, get: () => c };
})();

Q18. What is currying and how does it use closures? Medium

const add = a => b => a + b;
add(2)(3);   // 5

Q19. How does memoization use closures? Medium

function memoize(fn) {
  const cache = {};
  return x => x in cache ? cache[x] : (cache[x] = fn(x));
}

Q20. How do you implement a debounce with closures? Hard

function debounce(fn, ms) {
  let t;
  return (...args) => {
    clearTimeout(t);
    t = setTimeout(() => fn(...args), ms);
  };
}

Q21. How do closures enable data privacy? Medium


Q22. What is a function factory? Medium

const triple = (n => x => x * n)(3);
triple(5);   // 15

Q23. How do once-only functions use closures? Medium


Advanced

Q24. What is the difference between a closure and a regular function? Medium


Q25. How do closures interact with the garbage collector? Hard


Q26. Can two closures share state? Hard

function pair() {
  let v = 0;
  return [() => ++v, () => v];
}
const [set, get] = pair();
set(); get();   // 1

Predict the Output

Snippet 1

function make() {
  let x = 0;
  return { inc: () => ++x, val: () => x };
}
const m = make();
m.inc(); m.inc();
console.log(m.val());

Output:

2

Why: Both methods close over the same x, so two increments leave it at 2.


Snippet 2

const fns = [];
for (var i = 0; i < 3; i++) fns.push(() => i);
console.log(fns.map(f => f()));

Output:

[ 3, 3, 3 ]

Why: var shares one binding; all closures read the final i of 3. Use let for [0, 1, 2].


Snippet 3

const add = a => b => a + b;
const add5 = add(5);
console.log(add5(3), add5(10));

Output:

8 15

Why: add5 is a closure capturing a=5; each call supplies b.


Quick Revision Table

ConceptKey takeaway
Closurefunction plus captured lexical scope
Captureby reference, not snapshot
Loop bugvar shares, let per-iteration
Module patternIIFE returns public API, hides state
Curryingchained single-arg closures
Memoizationprivate cache in closure
Leak riskcaptured big object stays alive

Frequently Asked Questions

What is a closure in JavaScript in simple terms?

A closure is a function bundled with references to its surrounding lexical scope, so it can read and update outer variables even after the outer function has returned. Candidates report this is the single most asked JavaScript concept.

Why is the loop closure bug asked so often?

Because it tests whether you understand that var closures share one binding while let closures get a fresh binding per iteration. It is the most common closure trap in interviews.

What are practical uses of closures?

Data privacy with the module pattern, function factories and currying, memoization caches, debounce and throttle helpers, and event handlers that remember state. Interviewers expect at least two real uses.

Do closures capture the value or the variable?

The variable, by reference, not a snapshot of its value. That is exactly why a var-loop closure sees the final value while a let-loop closure sees its own iteration value.

Can closures cause memory leaks?

Yes. A reachable closure keeps its captured variables (and anything they reference) alive. Detach handlers and clear references in long-lived applications to let the garbage collector reclaim them.



Confirm any scope or closure detail on the official MDN documentation before your interview. This guide reflects candidate-reported patterns and public preparation resources as of June 2026.

advertisement
Sources and review notesreviewed 8 Jun 2026
Verification window
Page last edited 8 Jun 2026 by Aditya Sharma. A review date records an editorial edit, not a guarantee that every external fact is still current.
Evidence labels

Official notices, candidate reports, offer documents, and editorial practice questions carry different confidence levels. The visible source list lets you inspect the evidence instead of relying on a blanket verification badge.

Verification policy: /editorial-standards/. Found something incorrect? Submit a correction - we respond within 48 hours.

topic cluster

More resources in Interview Questions

Use the category hub to browse similar questions, exam patterns, salary guides, and preparation resources related to this topic.

Open Interview Questions hubBrowse all articles

paid contributor programme

Sat this this year? Share your story, earn ₹500.

First-person experience reports help future candidates prep smarter. We pay verified contributors ₹500 via UPI per accepted story with byline.

Submit your story →

ready to practice?

Take a free timed mock test

Put what you learned into practice. Our mock tests match the 2026 pattern with timer, navigator, reveal, and score breakdown. No signup.

Start free mock test →
related guides
more from PapersAdda
Exam PatternsInfosys Power Programmer Coding 2026: How PP Differs From SP
7 min read
Company Placement PapersAccenture Interview Process 2026: Rounds & Prep
5 min read
Company Placement PapersAccenture Interview Questions 2026 (with Answers for Freshers)
13 min read
Guides & ResourcesAdobe Interview Process 2026: Rounds, OA & Aptitude
10 min read

Share this guide