I just found out about using label s in JavaScript, such as:
for (var i in team) {
if(i === "something") {
break doThis: //Goto the label
} else {
doThat();
}
}
doThis: //Label
doIt();
I've not heard about this until now and I can't find much information online about it and I'm beginning to think there is a reason for that.
It seems to me like this is similar to a GOTO
statement in other languages and would be considered bad practice. Would I be right in assuming this?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…