How often do you use break/continue and labels?

For several years programming I have never used break/continue and labels

You have been the same?
How often do you use these opportunities?
June 26th 19 at 14:09
4 answers
June 26th 19 at 14:11
When you need to find one occurrence in a large array yuzal break, there in the beginning of the test was that if undefined then continue.

you can still optimize loops with a large number of occurrences using break to Bloch the user browser.
Something like this:
optimized–°ycle function(arr, i, func, done) {
 //maximum execution time in ms
 var maxExecutionTime = 100;
 var startTime = new Date().getTime();
 for (; i < arr.length; i++) {
 if (new Date().getTime() - startTime >= maxExecutionTime) {
 setTimeout(function() {
 optimized–°ycle(arr, i, func, done);
 }, 0);
 func(arr[i], i);
 if (i + 1 == arr.length) {


label never
June 26th 19 at 14:13
strange question... if objectives are not met need using, well, so be it, do not use....
And so, in switches and loops it found widespread use...
June 26th 19 at 14:15
break use sometimes. For example, unmatched parentheses in the line in a single pass.
June 26th 19 at 14:17
The label used for the last time in basic on the spectrum. For ongoing work in the legacy project are used in labels, but only to separate sections, none of them does not pass.

break is very convenient when it is necessary to sort the array before performing something. continue sometimes can be avoided by changing the condition in if otherwise.

Find more questions by tags JavaScript