I will use javascript as an example. I am confused because I have seen various answers as to what part "is" the closure. Is counterFunc the closure? Is incCount the closure? Is count the closure? I don't want to be at a job interview and point to the wrong part of the code and look like a poser : /
var counterFunc = function()
{
var count = 0;
var incCount = function()
{
count = count + 1;
return count;
};
return incCount;
};
var myCounter = counterFunc();
console.log(myCounter());
console.log(myCounter());