一,原始模式
var Cat = {
name : '',
color : '',
getName:funtion()
{
return this.name;
}
};
二,构造函数模式
function Cat(name,color){
this.name = name;
this.color = color;
this.type = "猫科动物";
this.eat = function() {alert("吃老鼠");};
}
三,原型模式
function Cat(name,color){
this.name = name;
this.color = color;
}
Cat.prototype.type = "猫科动物";
Cat.prototype.eat = function(){alert("吃老鼠")};