I have a couple of nested objects, where A is always a part of B.
May I use the following code to access owner's properties and methods?
function A( owner ) {
this.value = function () { return owner.value() + 1 };
}
function B() {
this.value = function () { return 1; };
this.a = new A( this );
}
var b = new B();
alert( b.a.value() );
Actually, it works. But I would like to know whether it is correct or not.