js中的继承

<script>
//js中的继承
function Animal(){
this.kind = "animal";
}
Animal.prototype.type = "water";
//绑定构造函数,原型中的属性和方法不会被继承。
function Cat(Name,Color){
this.Name = Name;
this.Color = Color;
Animal.apply(this.arguments);
}
var cat = new Cat("tom","watth");
console.log(cat);
//原型指向父类对象,继承父类中的所有属性和方法,包括原型中的内容
function Animal(){
this.kind = "animal";
}
Animal.prototype.type = "water";
function Cat(name,Color){
this.name = name;
this.Color = Color;
}
Cat.prototype = new Animal();
var cat = new Cat("tom","white");
console.log(cat);
</script>
原文地址:https://www.cnblogs.com/wtdall/p/10754337.html