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 0
0
相关文章
javascript对象如何创建_属性和方法怎样访问【教程】
javascript中的this指向如何确定【教程】
javascript中的“this”关键字指向什么?【教程】
javascript中的箭头函数有什么特点?【教程】
javascript箭头函数是什么_它与普通函数有什么区别【教程】
本站声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门AI工具









