JS Object Inheritance
by Ben Clayton
JavaScript
var infx={};
infx.forms = function(){
this.name='Bat';
this.price={net:2,vatrate:'20%'};
this.show=function(){
console.log("product name is "+this.name+", price net "+this.price.net+ ", vat rate "+this.price.vatrate);
};
};
var luco={};
luco.forms = function(){
this.price={net:4};
this.name='Ball';
};
luco.forms.prototype = new infx.forms;
var obj1 = new infx.forms();
var obj2 = new luco.forms();
obj1.show();
obj2.show();