Wanting to get something straight here...so I have 2 questions
The function below creates a closure.
function Foo(message){
var msg = message;
return function Bar(){
this.talk = function(){alert(msg); }
}
};
Q: Which function is the closure, Foo or Bar?
I always thought the closure to be Foo, because it closes-over Bar once Bar is returned.
Next...
Below is the definition of an anonymous function:
()();
Q: Is the inner-function within this anonymous function also a closure?
(function(){ /* <-- Is this function also a closure? */ })();