On 28/03/2012 15:09, Groupes wrote:
Thanks for these ideas.
I'm still not sure if I will use these sub objects, but here is the
solution I came for : http://jsfiddle.net/nBn2t/2/
In this case this.parent refers to the class' this and seems quite
coherent...
I'd still go with this.Child.a.call(this);
anyway, here's something interesting that has aroused my curiosity, use
console to see differences:
http://jsfiddle.net/nBn2t/12/
Trying to figure why they don't behave the same and why instance.method
is higher on the prototype chain than instance.child.method.
The obvious difference that comes to mind is that the object passed to
the Class constructor when defining our class gets 'lost', broken down
and cloned into the function prototype that it returns.
However, when instantiated, the function still returns a host object of
the same structure that will contain the Child object and then run the
initialize function, how is it different?
Perhaps i should read the source again but failing that would anyone
care to comment and explain why it does not work within the class? and
yes, i know __proto__ going away and all that.
Thanks in advance...