I need to make it so that every time a specific property on my object is changed - it will call a special method on the same object.
Example:
MyObject.prototype = Object.create({
specialMethod: function() { /* ... */ }
}, {
someValue: {
set: function(value) {
/* HOW DO I ASSIGN THE VALUE TO MyObject HERE?*/
/* I can't do: this.someValue=value, that would create endless recursion */
this.specialMethod();
}
}
});
How do I assign the value to MyObject within the property setter?