_call

源码

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

说明

模拟实现call方法

用法

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