Hey all, I finally understand that the closure is being passed to the returned function overloadSetter. The OP does understand prototype inheritance. I wasn't misunderstanding the inheritance, I was misunderstanding what function was being passed the arguments and how. Julian, thanks a bunch man, you were very helpful. I finally get that you could rewrite the function like this (sort of)
someFunc.extend(a,b) is equivalent to (again, kind of) someFunc.extend[the returned function of overloadSetter](a,b), wherein the context of the returned function of overloadSetter 'self' is the method 'extend'. Sorry if my question was completely unclear. Thanks again, Nate On Mon, Feb 28, 2011 at 8:29 AM, Julian Turner <[email protected]> wrote: > 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] > -- Nathan Sweet Web Developer 206.588.6137 nathansweet.me -- 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]
