JS 每一个 function 都有自己独立的运行上下文,但箭头函数不属于普通的 function,所以没有独立的上下文。
所以在箭头函数里写的 this 其实是包含该箭头函数最近的一个 function 上下文中的 this(如果没有最近的 function,就是全局)。
箭头函数中的 this
转载本文章为转载内容,我们尊重原作者对文章享有的著作权。如有内容错误或侵权问题,欢迎原作者联系我们进行内容更正或删除文章。
下一篇:如何写出优雅、简洁的代码
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
JavaScript箭头函数中的this详解
JavaScript箭头函数中的this详解 一、总结 一句话
ES6 javascript 取值 作用域链 sed