When you create a new function it has a "prototype" property, which
has a "constructor" property which refer to the created function:

function F(){};
F.prototype.constructor === F  =>  true

So you will be able to get the class of an instance:

var obj = new F;
obj.constructor === F  => true

When we redefine the "prototype" property of an function, their
"constructor" must be redefined too:

function G(){};
G.prototype = new F;
var obj = new G;
obj.constructor === F  // true !!not good!!
G.prototype.constructor = G;
obj.constructor === G  // true - ok

The special "__proto__" property is available only on Gecko engines,
and it is used to redefine the prototype chain... so it's not cross-
browser solution... my module for OOP in JS use this optimization too,
but it's not strictly necessary...

I hope this answer will help you,

Robert

On Sep 8, 4:12 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> I have seen the new inheritance code from Alex in 1.60 rc0, and I have
> a question: I believe the following two lines code are no use at all
>     method.prototype.constructor = method;
>     subclass.prototype.constructor = subclass;
> constructor property is no use at all, the usage property is __proto__
> and you can not alter it in IE, is there something I do not know about
> constructor property which is also very important?


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to