Trinithis
07-07-2007, 01:52 AM
As far as I can tell, the following do exactly the same thing:
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;
}
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?
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;
}
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?