I'm trying to create a global object with a series of 'slave' properties that are derived from the value of one 'master' property in the same object - something like:
var x = 5;
var myObj = {
master : 17,
slave1 : this.master + x,
slave2 : (this.master / 2.2) + 1,
slave3 : Math.floor(this.slave2)
//etc.
};
I realize this is horribly wrong as is, but the concept is there. What I'd like to do is have all these 'slave' properties updated as myObj.master
is updated. What's the cleanest way to do this? Does each slave value need to be explicitly set by some event handler that fires when myObj.master
is changed...?