Explain the concept of closure in JavaScript.

  • A closure is a JavaScript module for encapsulating private variables
  • A closure is a data structure for storing and accessing key-value pairs
  • A closure is a function that captures and remembers its outer scope variables
  • A closure is a function that has access to its parent scope variables
In JavaScript, a closure is a function that has access to its outer (enclosing) function's variables, even after the outer function has finished executing. This concept is fundamental for creating private variables and managing scope in JavaScript programs.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *