【发布时间】:2014-02-27 03:44:18
【问题描述】:
假设我有一系列函数:
function a(){
//do this, do that
b();
}
function b(){
//do this, do that
c();
}
function c(){
//do this, do that
// program ends at this point
}
a();
你会假设通过执行代码,我们从a() 到b() 到c() 并且程序终止......
我想知道的是...是否可以将代码放置在 b() 的 // do this, do that 部分中的某处,根据特定条件返回到 a() 然后继续进行而不需要返回 where它在b() 中停止,但如果需要可以重新启动b()?
我知道,你在想什么......“这是一个 JavaScript GOTO 问题,当然!”在某种程度上它是......但说真的,是否有可能完全脱离函数 A 并转到函数 B 而不必担心它返回到函数 A 以完成它停止的地方?
【问题讨论】:
-
depending on certain conditions to return to a()你回答了你自己的问题:return "value";:)
标签: javascript function goto