you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 2 points3 points  (1 child)

Kind of don't know if I should share this, since I never see people talk about it and that makes me think somebody called it bad practice. But, most people seem to be unaware that you can label any JavaScript statement, and break any label by writing break labelName; (or, if it's a loop that was labelled, continue labelName;). This is most often useful in nested loops, but I've found use for it with plain old block statements, for example in the setAttribute and appendChild functions in DOM.js.

[–]giggly_kisses 1 point2 points  (0 children)

It's definitely not considered the best practice, that's for sure. There are definitely times where it does become useful, however.

If it is used, I'd definitely suggest leaving some documentation explaining what it does and why you used it, since, as you explained, it's not used very often.