2013年5月14日

several way to implement inheritance in javascript

摘要: 1 //1.prototype chain inheritance 2 function SuperType() { 3 this.property = true; 4 } 5 SuperType.prototype.getSuperValue = function () { 6 return this.property; 7 }; 8 function SubType() { 9 this.subproperty = false;10 }11 12 //inherited from Su... 阅读全文

posted @ 2013-05-14 23:45 雷音 阅读(145) 评论(0) 推荐(0) 编辑

several way to create object in javascript

摘要: //factory model: function createPerson(name, age, job) { var o = new Object(); o.name = name; o.age = age; o.job = job; o.sayName = function () { alert(this.name); }; return o; } //constructor model: function Person(name, age, job) { this... 阅读全文

posted @ 2013-05-14 22:14 雷音 阅读(168) 评论(0) 推荐(0) 编辑

导航