Hi Rob

> > 1.   Inheritance in JavaScript is implemented through chains of
> > prototype objects, ending ultimately at Object.prototype.
>
> Strictly, it ends with the object referenced by the internal
> [[prototype]] property of Object.prototype, which is null.

Sorry, yes I should have said that.

>
> >  If you
> > access a property (including a property referencing a function - i.e.
> > a method) on an object, and the object does not have that property as
> > its own, then the interpreter will see if the the object's prototype
> > has that property,
>
> It uses the object referenced by an object's internal [[prototype]]
> property, which is (nearly always) a different object to that object's
> public prototype.

Ahh, ok.  I thought that the internal [[prototype]] was the same
object as the constructorfunction.prototype. I probably need to read
the spec again!

> > and if not whether that prototype's own prototype
> > has that property, and so on until it runs out at Object.prototype.
>
> The chain uses internal [[prototype]] properties, not public prototype
> properties.

Understood.  My answer was ambiguous on that point.

> But I think you're on the right track, the OP's problem seems to be
> not understanding prototype inheritance.

Thank you.  I think the OP may (apologies to OP if this is not the
case) also be missing what is happening with

function(){ primary }.overloadSetter()

- i.e. it is returning a new anonymous function with function()
{ primary } in the scope bound to the self variable.

Regards

Julian

-- 
To view archived discussions from the original JSMentors Mailman list: 
http://www.mail-archive.com/[email protected]/

To search via a non-Google archive, visit here: 
http://www.mail-archive.com/[email protected]/

To unsubscribe from this group, send email to
[email protected]

Reply via email to