<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script type="text/javascript">
var shape={
type:"triangle",
getType:function(){
return this.type;
}
};
function Triangle(a,b,c)
{
this.a=a;
this.b=b;
this.c=c;
}
Triangle.prototype=shape;
Triangle.prototype.getPerimeter=function()
{
return (this.a)*(this.b)*(this.c);
};
var t=new Triangle(4,5,6);
alert(t.getPerimeter());
alert(t.getType());
</script>
</head>
<body>
</body>
</html>
时间: 2024-10-28 23:31:18