Lets say I have a Javascript object:
var myObj = {
property1 : 20,
property2 : -20
}
But instead of -20 for property2, I need to take the value of property1 and convert it to its negative within property2:
var myObj = {
property1 : 20,
property2 : this.property1 * -1
}
This doesn’t work, but I think it illustrates what I want to accomplish.
I could suggest you the following
Edit
Seems that this is a dependant property so it is readonly. But I’ve edited the code so that it is also writable.