2014年4月11日

javascript中的继承-组合继承

摘要: 连续两篇水文(javascript中的继承-原型链,javascript中的继承-借用构造函数),这种行为完全是充数,这里结合两者的优点介绍组合继承模式:function SuperType(name){ this.name=name; this.friends=["gay1... 阅读全文

posted @ 2014-04-11 13:36 nU|| 阅读(207) 评论(0) 推荐(0) 编辑

javascript中的继承-借用构造函数

摘要: 接上篇:function SuperType(){ this.friends=["gay1","gay2"];}function SubType(){}SubType.prototype=new SuperType();var instance1=new SubType();var instance1.friends.push("gay3");alert(instance1.friends);var instance2=new SubType();alert(instance2.friends); alert(instance1 in 阅读全文

posted @ 2014-04-11 09:42 nU|| 阅读(1223) 评论(0) 推荐(0) 编辑

导航