I tried to call from child object a parent attribute
var parentObj = { attr1:1, attr2:2, childObj:{ method1:function(){ return this.attr1 * this.attr2; } } }
but it doesn't work.
Try referencing parentObj directly:
parentObj
var parentObj = { attr1: 1, attr2: 2, childObj: { method1: function () { return parentObj.attr1 * parentObj.attr2; } } }
1.4m articles
1.4m replys
5 comments
57.0k users