【问题标题】:Where is an Arrow function execution context?箭头函数执行上下文在哪里?
【发布时间】:2018-11-05 09:48:29
【问题描述】:

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

【问题讨论】:

    标签: javascript ecmascript-6 arrow-functions


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 2022-11-27
      • 2015-04-22
      • 1970-01-01
      • 2017-05-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多