Javascript 函数 Inner/Outer/Variable 作用域
Javascript Funciton Inner/Outer/Variable Scope
我已阅读 MDN:Scope 文档和其他资源,但感觉真的卡住了。
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()
theFunk()
funkyFunction
returns一个函数。您需要立即调用该函数,以便它 returns "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);
我已阅读 MDN:Scope 文档和其他资源,但感觉真的卡住了。
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()
theFunk()
funkyFunction
returns一个函数。您需要立即调用该函数,以便它 returns "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);