bar函数调用call方法,则this指向bar函数,所以只需改变call函数的this指向 Function.prototype.call=function(content){ content=content || window; content.fn=this; console.log(this); let arg=[...arguments].slice(1); let result=content.fn(...arg); delete content.fn return result }
|
近期评论