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?
doThis: for(...
– MahauhasOwnProperty
is definitely bad practice. See: bonsaiden.github.com/JavaScript-Garden/#hasownproperty – GullethasOwnProperty
. Nothing on theObject
prototype is enumerable. – Daugava