javascriptoop编程—实现继承的三种形式[1](1)模拟类的方式,我们都知道js是原型继承机制,不存在class和instance分离的这种方式假设,我们有两个类functionAnimal(){ this.name=“animal”; this.eat=function(){ consle.log(“eating"); }}functionCat(){ this.say=functi..
分类:
编程语言 时间:
2015-05-09 06:39:56
阅读次数:
307
window.onload=function(){ /*给函数原型增加一个extend函数,实现继承*/ Function.prototype.extend = function(superClass){ if(typeof superClass !== 'function'){ throw ...
分类:
Web程序 时间:
2015-04-24 12:30:05
阅读次数:
145
今天气真好,最近挂掉一些面试之后心情略失落。神马都是浮云,要永远做好世界第二。不多提了,你问我心态为啥变好了。-------都是情怀,,。嗯啊,最近在研究node。别人问?你这水平还node...哈哈哈,好伤心....不多提了,言归正传。神马模块化神马的先就不多讲了,就一个module.export...
分类:
Web程序 时间:
2015-04-13 18:05:38
阅读次数:
121
1.原型链function SuperType(){this.property = true;}SuperType.prototype.getSuperValue = function(){return this.property;};function SubType(){this.subprope...
分类:
Web程序 时间:
2015-04-10 12:59:23
阅读次数:
145
js继承有5种实现方式:1、继承第一种方式:对象冒充 function Parent(username){ this.username = username; this.hello = function(){ alert(this.username); } } function Child(user...
分类:
Web程序 时间:
2015-03-27 23:42:44
阅读次数:
173
1. 对象冒充 2. call方法 3. apply方法 4. 原型链方法 5. 混合方式
分类:
Web程序 时间:
2015-03-09 15:46:03
阅读次数:
187
第一种方法:对象冒充(临时属性)借用临时属性,指向超类,末了删除function Person(name,gender){ this.name=name; this.gender=gender; this.report=function(){ alert(this.name); }}functio....
分类:
Web程序 时间:
2015-02-02 19:50:19
阅读次数:
142
首先,推荐一篇博客豪情的博客JS提高篇: http://www.cnblogs.com/jikey/p/3604459.html ,里面的链接全是精华, 一般人我不告诉他; 我们会先从JS的基本的设计模式开始,由浅入深: 工厂模式:因为使用用一个接口创建很多对象会产生大量的重复代码,为了解决...
分类:
Web程序 时间:
2015-01-24 22:48:25
阅读次数:
265