//用代码实现bind函数
var obj = new Object();
function fn(a, b) {
console.log(this);
console.log(a + b);
}
Function.prototype.mybind = function(thisArg) {
var that = this; //暂存实例函数
var arr = Array.from(arguments);
arr.shift(); //得到参数数组
return function() {
that.apply(thisArg, arr);
}
}
fn = fn.mybind(obj, 1, 2);
fn();