箭头函数指向
来源:6-4 this 有几种赋值情况

weixin_慕前端9168190
2022-08-12
老师,遇到一个问题请教一下
const input1 = document.getElementById('input1')
input1.addEventListener('keyup', () => {
console.log(this) // this指向window
console.log(input1.value)
})
打印的this是指向window, 按课程说 箭头函数不是指向上级作用域,箭头函数现在的 上级作用域 现在不是指向 input1吗
写回答
1回答
-
双越
2022-08-13
“箭头函数不是指向上级作用域” —— 你在上级作用域打印一下 this ,看看是不是 input1 ?
00
相似问题