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)

 

posted @ 2013-05-16 16:52  践道者  阅读(185)  评论(0编辑  收藏  举报