<html>
<body>
<script>
//实现JavaScript继承的步骤:
//1:写父类
//2:写子类
//3:用Object.create()来实现继承
//4:该构造器
function Aminal(wz){//父类
this.wz = wz ;
}
Aminal.prototype.eat = function (){//父类方法
alert(this.wz+"食屎") ;
}
function Dog (name){//子类
Aminal.call(this,"前科动物") ;
this.name = name ;
}
Dog.prototype = Object.create(Aminal.prototype) ;//继承的实现
Dog.prototype.constructor = Dog ;//改构造器
var d = new Dog("旺财") ;
d.eat() ;//实现继承后调用父类的eat()方法
</script>
</body>
</html>