摘要: //动态原型模式function Box(name,age){ this.name = name; this.age = age; this.family = ['哥哥','姐姐','妹妹']; if(typeof this.run != 'function'){ ... 阅读全文
posted @ 2014-08-17 16:55 little fly 阅读(146) 评论(0) 推荐(0) 编辑
摘要: //组合构造函数+原型模式function Box(name,age){ //保持独立的用构造函数 this.name = name; this.age = age; this.family = ['哥哥','姐姐','妹妹']};Box.prototype ... 阅读全文
posted @ 2014-08-17 16:43 little fly 阅读(118) 评论(0) 推荐(0) 编辑
摘要: //原型创建对象function Box(){};Box.prototype.name = 'Lee';Box.prototype.age = 100;Box.prototype.run = function(){ return this.name + this.age + 'running.... 阅读全文
posted @ 2014-08-17 15:11 little fly 阅读(176) 评论(0) 推荐(0) 编辑
摘要: //构造函数创建对象function Box(name,age){ //创建一个对象 this.name = name; //添加一个属性 this.age = age; this.run = function(){ return this... 阅读全文
posted @ 2014-08-17 14:53 little fly 阅读(447) 评论(0) 推荐(0) 编辑