摘要: call, apply都属于Function.prototype的一个方法,它是JavaScript引擎内在实现的,因为属于Function.prototype,所以每个Function对象实例,也就是每个方法都有call, apply属性.既然作为方法的属性,那它们的使用就当然是针对方法的了.这两... 阅读全文
posted @ 2015-03-26 19:53 beggarWang 阅读(616) 评论(0) 推荐(0) 编辑
摘要: 复制继承:简单理解,就是把父对象上的所有属性复制到自身对象上; function Cat(){ this.climb = function(){ alert("我会爬树"); ... 阅读全文
posted @ 2015-03-26 19:38 beggarWang 阅读(253) 评论(0) 推荐(0) 编辑
摘要: 关键代码 this.parent = Cat; this.parent.apply(this); 1 function Cat(){ 2 this.climb = function(){ 3 al... 阅读全文
posted @ 2015-03-26 19:24 beggarWang 阅读(350) 评论(0) 推荐(0) 编辑
摘要: 有一只小狗叫花花,它会“汪汪”叫,他的同伴也会汪汪叫,后来环境发生了变化,新出生的狗不会再“汪汪”叫,而变成“呜呜”叫。试通过继承来达到目的 1 function Dog(){ 2 2 this.bark = function(){ 3 3 ... 阅读全文
posted @ 2015-03-26 18:56 beggarWang 阅读(325) 评论(0) 推荐(0) 编辑