SoFunction
Updated on 2025-03-03

Inherited instance code in javascript


function Polygon(iSliders){ //Define a polygon
=iSliders;
}
=function(){ //Define a method to degrade an area for a polygon
return 0;
}
function Triangle(iBase,iHeight){
(this,3); //Inherit polygon object
=iBase;
=iHeight;
}
=function(){ //Rewrite the method of removing the area
return 0.5**;
}
var triangle=new Triangle(15,8); //Instantiate a triangle
alert("Number of edges:"+);
alert("area:"+());