-
Inheritance Subtleties?
As far as I can tell, the following do exactly the same thing:
Code:
function House(location, cost) {
this.location = location;
this.cost = cost;
}
function Mansion(location, cost, size) {
this.parent = House;
this.parent(location, cost);
this.size = size;
}
Code:
function House(location, cost) {
this.location = location;
this.cost = cost;
}
function Mansion(location, cost, size) {
House.call(this, location, cost); //Or similarly with apply()
this.size = size;
}
Are there any differences whatsoever? If so, which technique is better?
-
Nope, no differences at all (other than the obvious, that the latter creates a parent property).