Technical

What is a closure in JavaScript?

Updated 28 September 2026 1 min read By LaunchCV.in

It shows depth in a core JavaScript concept.

Why interviewers ask this

It shows depth in a core JavaScript concept.

How to approach it

Define it simply and give a short counter example.

Example answer

A closure is a function that remembers variables from the scope where it was created, even after that scope has finished. For example, a function that returns another function that increments a private counter.

What a weak answer sounds like

A closure is a function inside a function.

It is vague, has no example and gives the interviewer nothing to remember.

Common mistake

Confusing closures with callbacks.

Follow-up questions to expect

  • Where are closures useful in real code?
  • What is the difference between var, let and const?
  • What is a common closure bug in loops?

How to practise

Write a small counter function using a closure and explain why the variable persists.

Use this as a pattern, not a script. Answer in your own words with your own examples.

Note: This is general information, not professional advice, and it cannot guarantee any job, admission, salary or result. Check official sources for current rules and dates.