javascript基础学习三:原型继承
function Animal() { this.species = "动物"; } function Cat(name, color) { this.name = name; this.color = color; } Cat.prototype = new Animal(); Cat.prototype.constructor = Cat; //重新把Cat的构造函数指回Cat var c2 = new Cat("大黄", "黄色滴"); console.log(c2.name); console.log(c2.species); console.log(Cat.prototype.constructor)