[Javascript] Question about best method of creating inheritance in javascript

Amanda Birmingham lists at imladris.com
Wed Apr 24 10:11:15 CDT 2002


Dan,
Thank you for the recommendation; could you be more specific about what you 
feel would be helpful in this chapter?  I have read Flanagan's Definitive 
Guide, and didn't immediately see any extra information in the recommended 
reading.

Perhaps I should have noted that I am familiar with javascript, and have 
used objects in it before ... my current mission is to try to track down 
info about the more esoteric aspects of inheritance so that I do it in a 
performance-friendly way (my new app will have a very large number of 
heavily-subclassed objects, and I don't want my chosen inheritance 
mechanism to create any more than are strictly necessary.)

Thanks for your time,
Amanda Birmingham
Web Application Developer

At 10:18 AM 4/24/2002 -0700, you wrote:

>I recommend you to read the chapter "Working with Objects" of "Client-Side
>JavaScript Guide" book:
>http://developer.netscape.com/docs/manuals/js/client/jsguide/obj.htm
>
>Dan.
>
>
>----- Original Message -----
>From: "Amanda Birmingham" <lists at imladris.com>
>To: <javascript at LaTech.edu>
>Sent: Tuesday, April 23, 2002 9:08 AM
>Subject: [Javascript] Question about best method of creating inheritance in
>javascript
>
>
> > Hello, List,
> > I'm new here, so please forgive any faux pas.  I've been gearing up to
> > write a very large OO javascript program, and have therefore been
> > investigating the different merits of possible ways of subclassing in
> > Javascript (yeah, I know "class" is a bit of a misnomer, but you know what
> > I mean :)
> >
> > So far, I've seen these three methods:
> > * make superclass constructor a method of subclass and call it inside the
> > subclass constructor (without the "new").  This takes the subclass object
> > and extends its "this" with the superclass info.
> >
> > * inside the subclass constructor, create a new instance of the
>superclass.
> > Then extend it and return that extended superclass as the subclass instead
> > of the the "this".
> >
> > * assign a new superclass object to the prototype property of the subclass
> > constructor function.
> >
> > Question 1:  when you create an instance of a subclass that inherits some
> > stuff, do all of these methods result in you *also* creating objects of
>all
> > the classes it inherits from?
> >
> > Question 2: If *so*, what is the advantage of the prototype method (which,
> > as I understand it, is the real, *approved* way of doing inheritance in
> > javascript), since it seems that using prototype has problems of blocking
> > access to methods of the superclass that have the same name as objects of
> > the subclass  (unless you use something like Kevin Lindsey's workaround) ?
> >
> > Answers, advice, and/or descriptions of other methods I've overlooked
>would
> > be gratefully welcomed.  Thanks,
> >
> > Amanda Birmingham
> > Web Application Developer
> >
> > _______________________________________________
> > Javascript mailing list
> > Javascript at LaTech.edu
> > https://lists.LaTech.edu/mailman/listinfo/javascript
>
>_______________________________________________
>Javascript mailing list
>Javascript at LaTech.edu
>https://lists.LaTech.edu/mailman/listinfo/javascript




More information about the Javascript mailing list