On Tue, Jun 14, 2011 at 8:57 AM, rohit jangid <[email protected]> wrote:
> thanks lucian.
>
> My view on inheritance was that.
> 1) first an empty object is created and it prototype points to
> constructor's prototype .
> 2) this object is passed into the constructor function where it can be
> refrenced by "this"
> 3) this is returned when we use new operator with constructor funtion .
>
> but as I tried to print what is stored in rj and rj.prototype , rj was
> empty object and rj.prototype was undefined. So how is it able to
> access that test() property .
I think what you are missing is that object [[prototype]] (notation
used by ECMA-262 for internal properties) references are *implicit*
links to their constructor's (explicitly referenced) prototype
property. This means that rj.prototype need not bear any relation to
the [[prototype]] of rj as used for inheritance purposes. IIUC, there
is no mechanism in the standard to look up an object's [[prototype]]
from user code (although some implementations provide extensions to do
this).
The core idea of this is documented in ECMA-262v3 section 4.2.1
("Objects") complete with a nice diagram. It can be obtained at
http://www.ecma-international.org/publications/standards/Ecma-262-arch.htm.
> the problem came when , an object was using different properties and I
> couldn't figured out how it was accessing them and what are the other
> available properties.
> _______________________________________________
> http://lists.parrot.org/mailman/listinfo/parrot-dev
>
_______________________________________________
http://lists.parrot.org/mailman/listinfo/parrot-dev