call()方法

let obj = {
name: "xuelei"
};

function fn() {
console.log(this);
const fn = () => console.log(this);
}

//call()方法改变函数内this指向
//此时this指向对象obj
fn.call(obj);

posted @ 2021-09-03 00:00  追风不跟风  阅读(48)  评论(0)    收藏  举报