HCLacids / resume

1 stars 0 forks source link

JS:apply实现 #32

Open HCLacids opened 2 years ago

HCLacids commented 2 years ago
Function.prototype.appFn =  function (targetObj = window, arr = []) {
    targetObj = new Object(targetObj)

    const key = Symbol('targetFnKey')
    targetObj[key] = this

    const res = targetObj[key](...arr);
    delete targetObj[key]
    return res;
}