Skip to content

Instantly share code, notes, and snippets.

@samuelsimoes
Created September 7, 2014 12:13
Show Gist options
  • Save samuelsimoes/f365b69c3ad29bb03daa to your computer and use it in GitHub Desktop.
Save samuelsimoes/f365b69c3ad29bb03daa to your computer and use it in GitHub Desktop.
window.Person = {
warnChangeInAttribute: function(attribute, pastValue, value) {
console.log(attribute + " changed from " + pastValue + " to " + value);
}
};
Object.defineProperty(window.Person, "name", {
get: function() {
return this.nameValue;
},
set: function(name) {
this.namePastValue = this.nameValue;
this.nameValue = name;
this.warnChangeInAttribute("name", this.namePastValue, this.nameValue);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment