2012年7月22日
摘要: 经常看 ,也经常忘, 所以先记录下来。。function Cat(name,color){ this.name = name; this.color = color; this.type = "猫科动物"; this.eat = function(){alert("吃老鼠");}; }这样的话 每次new Cat('cnblogs','white')的时候,都会生成一个type和eat属性,有多少个对象也就生成多少次但是这个两个属性是每个对象都是一致的,所以可以采用原型来出来:function Cat(name,color 阅读全文
posted @ 2012-07-22 16:25 cfd406635982 阅读(255) 评论(0) 推荐(0) 编辑