var Animal = function(name) {
this.name = name;
};
Animal.prototype = {
getName: function() {
return this.name;
}
};
var Cat = function(name) {
this.name = name;
// 继承构造函数父类中的属性和方法
// Animal.call(this, name);
};
function extends(sub, sup) {
var F = function() {};
F.prototype = sup.prototype;
sub.prototype = new F();
sub.prototype.constructor = sub;
sub.sup = sup.prototype;
if(sup.prototype.constructor === Object.prototype.constructor) {
// 检测超类原型的构造器是否为原型自身
sup.prototype.constructor = sup;
}
};
console