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; }
Are there any differences whatsoever? If so, which technique is better?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; }



Reply With Quote

Bookmarks