Subj : Re: Implementing inheritence? To : Brian Genisio From : Brendan Eich Date : Wed Jan 28 2004 12:45 pm Brian Genisio wrote: > Hi all, > > Is there a way in spidermonkey to have an object inherit all of a > parent's properties and methods? JS is all about delegation, not inheritance -- but the two look the same from many angles. If the first object O's prototype (__proto__ property in SpiderMonkey) refers to the second, P (the "parent"), then for any property X in P, O.X or O["X"] will access P.X or P["X"], unless there is a direct property of O named X (in which case O.X is said to "shadow" P.X). > Using the DOM as an example, class Document inherits from class Node. > Can I tell spidermonkey that this is the case, or do I have to > implement it myself. It looks pretty easy for me to do it myself, but > I thought I would check if there is an easy way. I couldnt find any. If you are implementing the DOM, you might want to look at Mozilla's DOM implementation. /be .