_bind

源码

https://github.com/ddzy/ts-utility-plugins/tree/master/src/ddzy/utility/function/_bind

说明

模拟实现原生bind方法

用法

index.ts
const origin = {
name: 'ddzy',
};
const target = {
printName(...args: any[]) {
console.log(this.name); // 'ddzy'
console.log(args); // [1, 2]
},
};
Function.prototype['_bind'] = utilityFunction._bind;
target.printName['_call'](origin)([1, 2]);