var Person = {
name : 'alice',
say : function(txt1,txt2) {
console.info(txt1+txt2);
console.info(this.name);
}
} var Dog = {
name : 'tom',
say : function(txt1,txt2) {
console.info(txt1+txt2);
console.info(this.name);
}
}
var arr = ['hello','hi'];
Person.say('hello','hi');
Dog.say('wang~','wang2~');
Person.say.call(Dog,'hello','hi');//Person.say内部的this指向了Dog,多个参数用逗号隔开
Person.say.apply(Dog,arr);//第二个参数是数组,参数数量可以是未知的
var PersonSay = Person.say.bind(Dog,'hello','hi');//不会立即执行,触发返回函数才会执行
PersonSay(); >>>hellohi
>>>alice
>>>wang~wang2~
>>>tom
>>>hellohi
>>>tom
>>>hellohi
>>>tom
>>>hellohi
>>>tom

最新文章

  1. spark on yarn 提交任务出错
  2. react1
  3. HTML5 Canvas核心技术图形动画与游戏开发(读书笔记)----第一章,基础知识
  4. 提供给Android和iOS开发人员的UWP移植向导
  5. Red Hat dhclient
  6. 网上流行的add(2)(3)(4)
  7. DevExpress XtraReports 入门五 创建交叉表报表
  8. AppBarLayout学习笔记
  9. Mysql,zip格式安装、修改密码、建库
  10. LNMP环境的安装
  11. flask开发表单
  12. 最小公共祖先 (Tarjan) POJ1470
  13. 20190321xlVBA_汇总表按模板生成明细表
  14. [YARN] 2.2 GB of 2.1 GB virtual memory used. Killing container.
  15. maven 打 fat包(jar包有了全部依赖)插件
  16. 每天一个linux命令: /etc/group文件详解
  17. Linux服务器同步时间
  18. 【我的Android进阶之旅】Android 源代码中的Java代码中//$NON-NLS-1$ 注释是什么意思?
  19. .net core系列之《新一代的配置系统Configuration在支持多数据源,热更新,层级化方面代码快速实践》
  20. 如果plsql连接没问题,但程序中报ORA-12504的错误

热门文章

  1. Android使用GestureDetector实现手势滑动效果
  2. android 通用菜单条实现(一)
  3. wordpress相关
  4. HashMap源代码剖析
  5. luogu2278 [HNOI2003]操作系统
  6. 在ubuntu中安装photoshop cs6
  7. word2vec和word embedding有什么区别?
  8. Android单选中listview中的一项
  9. PCB Genesis增加点阵字 实现原理
  10. Tunnel Warfare(树状数组+二分)