"... in this question, the required property is a direct descendant of 'this', which is not the case in the above example"
Actually, maybe you are calling .discount() from the productN object.
Therefore, you would not use this.product1.price , because if you call discount from productN , then this will be a link to productN .
Just do the following:
this.price; this.price_was;
... so it will look like this:
var obj = { product1: { price: 80, price_was: 100, discount: function(){ return 100 - (100 * (this.price/this.price_was)); } } };
Again, it is assumed that you are calling a function from the productN object. If not, it would be useful if you showed how discount is called.
source share