javascript - 箭头函数执行上下文在哪里?
问题描述
我正在阅读Execution Context in JavaScript
一篇文章,我无疑明白什么是JavaScript
.
function Foo() {
// Execution context of Foo function is here, between curly braces
}
我还阅读了Arrow Functions
它及其属性,但我遇到了一个问题:
箭头函数执行上下文在哪里?
const ArrowFoo = () => {
// Where is ArrowFoo function execution context?
// Is here? or the upper block scope?
// Or global scope?
}
解决方案
箭头函数的执行上下文是与所有其他函数一样的函数执行上下文。
与此类似foo
,箭头函数的主体(在大括号之间)包含在此执行上下文中执行的代码。
推荐阅读
- mysql - 如何使用mysql查询将datagridview中的文本框列替换为复选框列
- python - 无法从 Python 函数内部访问导入的模块
- javascript - 如何在弹出窗口中使用脚本中的变量
- python - 多处理仅适用于第一次迭代
- excel - 如何在excel 2013中按日期和时间过滤日期?
- c++ - 如何在二维向量 i,j 上设置条件
- c++ - C ++:语法错误:'string'但在另一个项目中仍然编译成功?
- javascript - Javascript:如果按下某个键,则停止鼠标移动事件
- javascript - 我可以制作带有两个类别轴的水平条形图吗?
- spring - Springboot mongo docker-compose 连接失败