javascript基础学习二:prototype

function Cat(name, color)
{
    this.name = name;
    this.color = color;
}

Cat.prototype.type = "猫科动物";
Cat.prototype.eat = function(){
    console.log("吃鱼吃老鼠");
}

var c1 = new Cat("Tom", "black");
console.log(c1.type);
c1.eat();
//检测类与对象人性关系:isPrototypeOf
Cat.prototype.isPrototypeOf(c1) //true
posted @ 2013-05-16 16:20  践道者  阅读(158)  评论(0编辑  收藏  举报