function Temp() {
return {
setHot: function(v) { this.hot=v },
getHot: function() { return this.hot; },
hot: false
}
}
var w = new Temp();
w.setHot(true);
w.hot !== w.getHot()
This, i believe, is what you would need to do for it to work. No need at all for the isHot var at all. The get set methods then directly edit the objects hot value, which means both getHot() and w.hot will return the right value.
If you wanted to make the isHot value private, then i believe you would need to use the isHot var, but you would not need or reference the w.hot value at all. Not sure what the consequences of such an action would be.
function Temp() {
var isHot = false;
return {
setHot: function(v) { isHot=v },
getHot: function() { return isHot; }
}
}
var w = new Temp();
w.setHot(true);
w.getHot();
However you can not access w.isHot, essentially private var.
Related articles perhaps..