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])