[Project_owners] JavaScript prototype question

Pawel Chmielowski prefiks at civ.pl
Tue Dec 6 21:52:48 EST 2005

Adam Judson napisał(a):
> Thanks,
>   works perfectly.
> Now can you explain why...
> I get that __proto__ works, it's a tricky Mozilla thing.
> Why didn't any of:
>   A.prototype.prototype

"prototype" slot is only defined in functions, A.prototype is object, so 
it doesn't have one.

__proto__ is equivalen of prototype for objects.

>   A.prototype.constructor.prototype

This is drawback of A.prototype = {...} since now 
A.prototype.constructor === {...}.contructor === Object If you need to 
have working constructor slot you need to store new properties in old 
prototype object, or you can set contructor in new object, but this will 
be visible in for (i in obj) loop.

   Pawel Chmielowski

More information about the Project_owners mailing list