// bind 的原型实现封装实现 !!!
Function.prototype.ibind = function (_this) {
var __this = this; // 获取使用ibind 的对象
var fixedArgs = [].slice.call(arguments).slice(1); //固定的参数
return function () {
__this.apply(_this, fixedArgs.concat([].slice.call(arguments))); //拼接参数
}
}
function foo() {
console.log(this,arguments);
}
// foo.ibind();
var poo = foo.ibind({
name: "ok"
}, 1, 2,33,3333);
poo(3, 4);