function foo() { return this.bar;}foo = foo.bind({bar:1});foo = foo.bind({bar:2});foo();要让这里的foo()输入2,我的答案是:Function.prototype.bind = function(obj,arg){ var that = this; return function(){ return that.call(obj,arg); }};function foo() { return this.bar;}foo = foo.bind({bar:1});foo = foo.bind({bar:2});foo();然而输出1
添加回答
举报
0/150
提交
取消