function person(){
   this.name = 'taobao';
   this.showMess = function(){
      return this.name;
   }
}
person.prototype.getVal = function(){
   return "hellow word";
}
function child(){
   person.call(this);
   this.num = 123;
}

//提供一个寄生函数
function _initJS(p,c){
   var val = Object(p.prototype);
   val.constructor = c;
   c.prototype = val;
}
//调用寄生
_initJS(person,child);

//这里记得放在后面定义child
child.prototype.showNum = function(){
   return this.num
}

(){
   return this.num
}
var c2 = new child()
undefined
c2.getVal()
"hellow word"
c2.showMess()
"taobao"
c2.showNum()
123

最新文章

  1. android之二维码扫描的实现
  2. iframe框架嵌套技巧(全屏,去双滚动条)
  3. 怎样计算一个整数的位数&并把每一位上的数字保存下来
  4. u盘文件系统故障的修复方法
  5. 【LEETCODE OJ】Binary Tree Postorder Traversal
  6. 上机实践 - - 一个例子了解C/C++中指针与数组的区别
  7. linux它SQL声明简明教程---WHERE
  8. twisted学习笔记 No.2 WebServer
  9. ios 初体验<页面切换>
  10. JAVAscript学习笔记 js条件语句 第三节 (原创) 参考js使用表 (2017-09-14 15:55)
  11. 强大的MobaXterm
  12. 《深入理解Java虚拟机》——Java内存区域与内存溢出异常
  13. RTMPdump(libRTMP) 源代码分析 9: 接收消息(Message)(接收视音频数据)
  14. font-size:0的妙用,用于解决inline或者inline-block造成的间隙
  15. poj2417 bsgs算法非逆元模板,用于求解A^x=B(mod C)的方程
  16. javascript闭包和this对象
  17. 深度学习笔记(八)Focal Loss
  18. 一个canonical标签解决site不在首页的问题
  19. Linux-(inotify-tools&rsync)
  20. unity3d Matrix4x4列为主序

热门文章

  1. Python dataframe中如何使y列按x列进行统计?
  2. sql排名函数--四个
  3. 51Nod 蜥蜴和地下室(搜索)
  4. CentOS7.4-btrfs管理及使用
  5. php八大设计模式之桥接模式
  6. 修改route.php文件对ThinkPHP快速注册路由
  7. [笔记-统计学习方法]感知机模型(perceptron) 原理与实现
  8. [洛谷P1343]地震逃生
  9. man帮助
  10. CRC校验的C语言实现