Javascript函数的内部/外部/变量范围

时间:2020-04-05 08:35:07

标签: javascript variables scope

我已经阅读了MDN:Scope文档和其他资源,但确实感到很困惑。

/path/to/dSYMs

1 个答案:

答案 0 :(得分:0)

funkyFunction返回一个函数。您需要立即调用该函数,以便它返回"FUNKY!"并分配给theFunk

var funkyFunction = function() {
  return function() {
    return "FUNKY!"
  }
}

// We want to set theFunk equal to "FUNKY!" using our funkyFunction.
// NOTE: you only need to modify the code below this line.

var theFunk = funkyFunction()();
console.log(theFunk);

相关问题