function Shape(edge) { this.edge = edge; } Shape.prototype.getArea=function(){ return 0; } Shape.prototype.getEdge=function(){ return this.edge; } function Triangle(bottom, height) { Shape.call(this,3); this.bottom = bottom; this.height = height; } Triangle.prototype = new Shape(); Triangle.prototype.getArea=function(){ return 0.5 * this.bottom * this.height; } function Rectangle(bottom, height) { Shape.call(this,4); this.bottom = bottom; this.height = height; } Rectangle.prototype = new Shape(); Rectangle.prototype.getArea=function(){ return this.bottom * this.height; } var triangle = new Triangle(4,6); alert(triangle.getEdge()); //3 alert(triangle.getArea()); //12 var rectangle = new Rectangle(4,6); alert(rectangle.getEdge()); //4 alert(rectangle.getArea());//24