重写bind方法
程序员文章站
2022-04-13 13:21:36
...
var that = null;Function.prototype.bind = function(obj,arg){ if (that == null){ that = this } return function(){ return that.call(obj,arg); } };function foo() { return this.bar; } foo = foo.bind({bar:1}); foo = foo.bind({bar:2});var result = foo(); console.log(result);//2
以上就是重写bind方法的详细内容,更多请关注其它相关文章!
上一篇: PHP中iconv函数知识汇总,phpiconv函数汇总
下一篇: C++多线程编程On Linux