Funtion.prototype.call_ = (target, ...arguments) => {
target = target || window;
const symbolKey = Symbol();
target[symbolKey] = this;
const res = target[symbolKey](...arguments);
delete target[symbolKey];
return res;
}
Function.prototype.apply_ = (target, arguments) => {
target = target || window;
const symbolKey = Symbol();
target[symbolKey] = this;
const res = target[symbolKey](...arguments);
delete target[symbolKey];
return res;
}
Function.prototype.bind_ = (target, arguments) => {
target = target || {};
const symbolKey = Symbol();
return function(rest) {
target[symbolKey] = this;
const res = target[symbolKey](...argyments, ...rest);
delete target[symbolKey];
return res;
}
}
标签:...,const,target,symbolKey,bind,call,arguments,res,apply From: https://www.cnblogs.com/hamili/p/16612537.html