You could probably use goto.js (http://summerofgoto.com/) to handle this with the exact loop that you're trying to use, but you should consider just finding a different way to factor your code.
Moving on deep function [closed]
-
23-06-2022 - |
Вопрос
I have a short question: How can I move from A
to B
in this code:
for(var i=0;i<length;i++)
{
B <--------------- So far
if (/*condition*/)
{
if(/*condition*/)
{
.....
}
else {
A <------------ From here
};
}
else if(/*condition*/)
{
...
}
}
I know about break
and continue
, but it doesn't work here
Thanks all!
Решение
Другие советы
Recursion
for(var i=0;i<length;i++) {
someFunc(i);
}
function someFunc(i){
if (/*condition*/){
if(/*condition*/) {
} else {
return someFunc(i) //change i to prevent infinite loop
}
} else if(/*condition*/ ) {
}
}
Не связан с StackOverflow