In this accepted popular answer the closures are explained. I understand the concept and can use it, but my question is rather terminological, look at this simple example:
function foo(x) {
var tmp = 3;
function bar(y) {
alert(x + y + (++tmp)); // will alert 16
}
bar(10);
}
foo(2);
So what exactly should be called a closure here: bar
? or foo
? or tmp
? Or all of them together?
You see how community wiki is calling bar
a closure, is that exactly right? Then how do I refer in a conversation to tmp
and to foo
? Are they also called closure, or variable inside a closure and closure accessor or whatever else? Or bar is called external closure and foo is internal closure?