Why this code returns 43
as the result, I expect it to result 42
. The code is as follows:
function say667() {
// Local variable that ends up within closure
var num = 42;
var say = function() { console.log(num); }
num++;
return say;
}
var sayNumber = say667();
sayNumber();