首页 > 解决方案 > 箭头函数执行上下文在哪里?

问题描述

我正在阅读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?
}

标签: javascriptecmascript-6arrow-functions

解决方案


箭头函数的执行上下文是与所有其他函数一样的函数执行上下文。

与此类似foo,箭头函数的主体(在大括号之间)包含在此执行上下文中执行的代码。


推荐阅读