做网站猫腻大吗,代理销售公司如何注册,wordpress图片seo,wordpress没有安装主题一、箭头函数中的this指向
箭头函数的this指向通常有两种情况
如果箭头函数处在一个普通函数之中#xff0c;那么他的this指向与包裹他的外层函数的this指向一致。其他情况下箭头函数中的this都指向window
let obj {fn:function(){console.log(我是普通函数,this obj) …一、箭头函数中的this指向
箭头函数的this指向通常有两种情况
如果箭头函数处在一个普通函数之中那么他的this指向与包裹他的外层函数的this指向一致。其他情况下箭头函数中的this都指向window
let obj {fn:function(){console.log(我是普通函数,this obj) // truereturn (){console.log(我是箭头函数,this obj) // true}}
}
console.log(obj.fn()())let obj {fn:(){console.log(this window);}
}
console.log(obj.fn())
// true二、箭头函数不能当做构造函数不能用new来创建实例。
三、箭头函数内没有普通函数绑定的arguments对象。
四、使用call、apply、bind无法改变箭头函数的this指向。