Javascript 将值返回到另一个嵌套函数中的函数

Javascript 将值返回到另一个嵌套函数中的函数,javascript,function,nested,return,Javascript,Function,Nested,Return,所以我有了这个javascript代码。有两个嵌套函数。如何将值返回到funcB()内部的funcA() 如果不这样做,这是可能的吗 function funcA() { let returnValueA; funcB(() => { //change returnValueA inside here }) return returnValueA; } 简言之,没有 return语句仅定义从其所属函数返回的内容。在您的示例中,return

所以我有了这个javascript代码。有两个嵌套函数。如何将值返回到
funcB()
内部的
funcA()

如果不这样做,这是可能的吗

function funcA() {
    let returnValueA;
    funcB(() => {
        //change returnValueA inside here
    })
    return returnValueA;
}

简言之,没有


return
语句仅定义从其所属函数返回的内容。

在您的示例中,
returnValueB
未定义,
funcB
从未调用,
returnValueA
从未使用。。。所以答案是一个菠萝。我认为关键字是“递归”@agentp-No。如果
funcA
有条件地调用它自己,那就应该是这样。这取决于
funcB
做了什么。如果它是一个同步回调,那么您可以做一些事情,并且/或者
funcB
应该适当地处理返回值。如果是异步回调,那就没有办法了。@Quentin的确,这个问题已经被彻底地重复了好几次。但是如果
funcB
是同步的,它仍然是,
returnfuncb(…)
,并返回回调创建的值。
function funcA() {
    let returnValueA;
    funcB(() => {
        //change returnValueA inside here
    })
    return returnValueA;
}