Skip to main content

What is a closure?

Entry JavaScript
Quick Answer A closure is a function that remembers the variables from its outer scope even after the outer function has returned. The inner function "closes over" those variables. Common use: factory functions, data privacy (like private variables), and callbacks that need access to loop variables. Every function in JavaScript is a closure.

Answer

A closure is a function that retains access to its lexical scope even after the outer function has returned.

S
SugharaIQ Editorial Team Verified Answer

This answer has been peer-reviewed by industry experts holding senior engineering roles to ensure technical accuracy and relevance for modern interview standards.

Want to bookmark, take notes, or join discussions?

Sign in to access all features and personalize your learning experience.

Sign In Create Account

Source: SugharaIQ

Ready to level up? Start Practice