prototype继承,,显示不出来呀
<!DOCTYPE html><html>
<head>
<meta charset="utf-8">
</head>
<body>
<script>
function Car() //基类
{
this.color="white";
this.size="middle";
this.set=function set(color,size){this.color=color;this.size=size;}
this.run=function(){return "I can run";}
this.voice=function() {return "I can voice";}
}
function Bus() //子类
{
Bus.prototype=new Car();
Bus.prototype.constructor=Bus;
this.kkk=function kkk(){return "KKK";}
}
function Truck()
{
Truck.prototype=new Truck();
Truck.prototype.constructor=Truck;
this.kkk=function kkk(){return "kkk";}
}
var bus=new Bus();
bus.set("white","middle");
alert(bus.color);
alert(bus.run());
var truck=new Truck();
truck.set("grey","big");
alert(truck.size);
alert(truck.voice());
</script>
</body>
</html>