Creating a variable to act as a flag to pass to the outer loop is one way, however, JavaScript provides labels which I think makes the code easier to read as well as reduce the amount of code:
outerloop:
while(valid){
for(loop through associative array){
if(!valid){
break outerloop;
}
}
}
Here's some info on labels here Scroll down to the label section. You could even do a continue to the outerloop.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…