Function.prototype.mybind = function (context, ...args1) {
// 判断是否为函数
if (typeof this !== 'function') {
throw new Error('Error');
}
// 默认绑定对象为window
context = context || window;
// 指向函数的this
_this = this;
return function (...args2) {
return _this.apply(context, args1.concat(args2));
}
} var name = 'window'; var hello = {
name: 'hello',
fn() {
console.log(this.name);
console.log(...arguments);
}
} var world = {
name: "world"
} hello.fn.mybind(world, 1, 2, 3)(4);

执行结果:

world

1 2 3 4

最新文章

  1. SQL字符串函数
  2. python 学习第五天,python模块
  3. php实现设计模式之 抽象工厂模式
  4. 【暴力模拟】UVA 1594 - Ducci Sequence
  5. Python 参数传递
  6. [转]Windows7 64bit下配置Apache+PHP+MySQL
  7. axure7.0下载安装教程
  8. GoldenGate 传统抽取进程随 DataGuard 主备快速切换的方案(ADG 模式)
  9. DDctf 新得
  10. 关于Python课程的思考和意见
  11. python--面向过程编程与面向对象编程
  12. jdk的卸载及安装+环境变量的配置
  13. Android Studio快速集成讯飞SDK实现文字朗读功能
  14. laravel服务l队列资料整理
  15. hive之案例分析(grouping sets,lateral view explode, concat_ws)
  16. Dice 7 ==> dice 5
  17. With语句上下文管理
  18. 撩课-Java每天10道面试题第7天
  19. Notes 20180309 : String第一讲_char的可读序列
  20. 洛谷 U14475 部落冲突 【比赛】 【树链剖分 + 线段树】

热门文章

  1. Myeclipse启动WebLogic 总是报账号密码无效<Authentication denied: Boot identity not valid
  2. ASP.NET MVC 四种Controller向View传值方法
  3. 2020年的六种编程语言排名中,java排第几只有不到1%的人知道
  4. JavaWeb项目在浏览器点击几次就阻塞了
  5. JavaScript之DOM的增删改查
  6. The Shortest Statement CodeForces - 1051F 最小生成树+并查集+LCA
  7. 31道Java核心面试题,一次性打包送给你
  8. EM算法理论与推导
  9. python 装饰器(八):装饰器实例(五)函数装饰器装饰类以及类方法
  10. tolua-ToLua#暖更新