摘要:
1 //类定义(prototype 模式) 2 function Cat(name,color) { 3 this.name = name; 4 this.color = color; 5 } 6 Cat.prototype.type = 'cat'; 7 Cat.prototype.food = 'fish'; 8 Cat.prototype.eat = function() { 9 alert(this.name + ' is eating '+this.food);10 };11 12 //使用13 var cat1 = new Cat(& 阅读全文