call()方法

时间:2021-09-03 20:08:35   收藏:0   阅读:13

let obj = {
name: "xuelei"
};

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

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

原文:https://www.cnblogs.com/zhuifeng-/p/15221385.html

评论(0)
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!