function Animal(name) {
console.log("父类构造函数----->", this);
this.name = name || "Animal";
this.sleep = function () {
console.log(this.name + "正在睡觉!");
};
this.getName = function () {
console.log(this.name);
};
}
Animal.prototype.eat = function (food) {
console.log(this.name + "正在吃:" + food);
};
function Cat_6(name) {
Animal.call(this);
this.name = name || "Tom";
}
(function () {
var Super = function () {};
Super.prototype = Animal.prototype;
Cat_6.prototype = new Super();
})();
var cat_6 = new Cat_6();
console.log("F-1:", cat_6.name);
console.log("F-2:", cat_6.sleep());
console.log("F-3:", cat_6 instanceof Animal);
console.log("F-4:", cat_6 instanceof Cat_6);
Cat_6.prototype.constructor = Cat_6;