Function.prototype.myApply = function (context) { var context = context || window context.fn = this var args = [...arguments].slice(1) if (!args) { var result = context.fn() } else { var result = context.fn(...args[0]) } delete context.fn return result } function People(name,age){ this.name=name this.age=age this.sayName=function(){ console.log(arguments) console.log(this.name+' '+this.age) } } function Stu(name,age){ this.name=name this.age=age } var obj={ name:'xiaozhang', age:1, sayName:function(name,age){ this.name=name this.age=age console.log(this.name+' '+this.age) } } var stu=new Stu("tom1",18) var people=new People("mary",20) people.sayName.myApply(stu,["jerry",14])