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
The above is the detailed content of Override bind method. For more information, please follow other related articles on the PHP Chinese website!