I tried to call from child object a parent attribute
var parentObj = { attr1:1, attr2:2, childObj:{ method1:function(){ r
This is an another approach without referencing the parent object's name.
var parentObj = { attr1: 1, attr2: 2, get childObj() { var self = this; return { method1: function () { return self.attr1 * self.attr2; } } } }
Can be accessed as:
parentObj.childObj.method1(); // returns 2