Subclassing, Inheritance, RE subclass "constructor" and inherited members

Discussion in 'Javascript' started by vbgunz, Aug 28, 2007.

  1. vbgunz

    vbgunz Guest

    // Referring to JavaScript the Definitive Guide: 9.5 through 9.5.2

    // the base and sub classes are perfect. the following code is an
    // example case, regarding WHY delete base members from a subclass
    // AND what is wrong with the loops ONLY returning -> prototype :/

    // Ex 01:
    print(subInstance.hasOwnProperty("baseMember")); // false
    for (var p in SubClass){
    print(p);
    } //
    prototype


    // Ex 02:
    delete SubClass.prototype.baseMember; // Don't need to customize,
    delete?
    print(subInstance.hasOwnProperty("baseMember")); // false
    for (var p in SubClass){
    print(p);
    } //
    prototype

    // Why delete the members in subclass if I inherit them from
    baseclass? is it
    // the same reason you might want to put constants & methods in the
    prototype?
    // Is it to avoid duplication and memory hogging? e.g., I don't
    actually need
    // to override the base members so should I really delete them from
    subclass?

    // Why iterating over the properties in the subclass yield ONLY ->
    prototype?
    // shouldn't I at least get all properties back defined in ALL classes
    (Ex 01)
    // AND after deleting those inherited from base on sub, shouldn't I at
    least
    // get those properties of sub (Ex 02)? Both Examples, have several
    members!
    vbgunz, Aug 28, 2007
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. jstorta
    Replies:
    3
    Views:
    427
    jstorta
    Feb 20, 2006
  2. lovecreatesbeauty
    Replies:
    43
    Views:
    1,284
    Keith Thompson
    Feb 6, 2006
  3. lovecreatesbeauty
    Replies:
    2
    Views:
    575
  4. ingoweiss
    Replies:
    4
    Views:
    200
    Julian Turner
    May 12, 2006
  5. vbgunz
    Replies:
    6
    Views:
    148
    Dr J R Stockton
    Sep 1, 2007
Loading...

Share This Page