Here's a piece of code.
var inner = '1';
var obj = (function () {
var inner = '2';
return {
inner: '3',
say: function () {
console.log(inner);
}
}
})();
obj.say();
Why is say()
printing '2' in the end? Not '1' or '3'? Can anyone explain the inner logic in it? Thank you.