Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Javascript (http://www.velocityreviews.com/forums/f68-javascript.html)
-   -   Subclassing, Inheritance, RE subclass "constructor" and inherited members (http://www.velocityreviews.com/forums/t932615-subclassing-inheritance-re-subclass-constructor-and-inherited-members.html)

vbgunz 08-28-2007 08:37 PM

Subclassing, Inheritance, RE subclass "constructor" and inherited members
 
// 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!



All times are GMT. The time now is 10:04 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.