V
vbgunz
// 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 loop ONLY
// returning -> prototype :/
// Ex 01:
print(subInstance.hasOwnProperty("baseMember")); // false
for (var p in SubClass){
print(p);
} // prototype
// Ex 02:
delete SubClass.prototype.baseMember; // not customizing, 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!
// 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 loop ONLY
// returning -> prototype :/
// Ex 01:
print(subInstance.hasOwnProperty("baseMember")); // false
for (var p in SubClass){
print(p);
} // prototype
// Ex 02:
delete SubClass.prototype.baseMember; // not customizing, 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!