SOURCE

Function.prototype.myApply = function (context, args) {
    context.fn = this
    let res = context.fn(...args)
    delete context.fn
    return res
}

let obj = {
    name: "aaa",
    getName: function (a, b) {
        console.log(this.name, a, b)
    }
}

let obj2 = {
    name: "bbb"
}
obj.getName.myApply(obj2, [1, 2])
console 命令行工具 X clear

                    
>
console