Can someone explain why the private variable, _a, isn't being updated with the setter? I must be missing something really obvious but can't see it.
var f = function(a){
var _a = a;
return {
getA : _a,
setA : function(e){
_a = e;
}
}
};
var d = f(1);
console.log(d.getA); // 1
d.setA(2);
console.log(d.getA); // 1
I thought that the second call should return 2
code here - http://jsfiddle.net/JUKWN/