Edit in JSFiddle

var $result = $("#result");
var Counter = function () {
  var count = 0,
    self = this;
  self.onChange = undefined;
    
  self.__defineGetter__("count", function (){
      count++;
      if(self.onChange) self.onChange("count:get called: " + count);
    return count;
  });
    
  self.__defineSetter__("count", function(val){
      if(self.onChange) self.onChange("count:set to: " + val);
    count = val;   
  });
};

function print(value){
  $result.append(value + "</br>");
}

var counter = new Counter();
counter.onChange = print;

counter.count;
counter.count;
counter.count;
counter.count;
print("");
counter.count = 50;
counter.count;