What exactly does "closure" refer to in JavaScript?

Viewed 16929

I understand what closures are, but I am having some trouble grokking exactly what the term closure refers to. I have seen the term used in many websites, but rarely do they agree on the actual definition of it.

  • Is it the variables that are kept on the stack frame?
  • Is it the function that is being returned?
  • Is it the scope of the outer function?
  • Is it the scope of the inner (returned) function?
  • Is it maybe the concept of keeping the variables on the stack-frame after returning the function?

Can someone tell me exactly to what closure refers to?

8 Answers

Closure means a function(outer function) containing another function(inner function).

Closure is used to protect the data.

the use of closer is demostrated in the video link provide below:

https://www.youtube.com/watch?v=w1s9PgtEoJs

Related