Welcome to MLink Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
379 views
in Technique[技术] by (71.8m points)

箭头函数和普通函数的this指向

在没有applybindcall的情况下

箭头函数的this是不是指向调用者的指向
而普通函数的this指向调用者?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

普通函数调用,this指向调用者(无主的this指向window,严格模式下是undefind),函数被当作构造函数使用,里面的this指向生成的对象。

箭头函数没有自己的作用域,也就没有自己的this,它里面的this其实是外层作用域的this。


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to MLink Developer Q&A Community for programmer and developer-Open, Learning and Share
...