Skip to main content
2 of 2
code example of using function calls vs continue/break statements
slickplaid
  • 1.4k
  • 1
  • 17
  • 21

I recently had this issue and I resolved it by using all lowercase in the loop's label in version v0.8.x of Node.js.

Using labelname: vs. iCantThinkOfAGoodLabelName: might help you.

Others have correctly corrected you on the location of the label. It should be immediately before the for loop.

The Mozilla Developer Network on labels advises to avoid using labels, and instead prefer calling functions or throwing an error. You might rethink your strategy on using them, if possible.

Example of calling a function depending on result:

var i, j;

for (i = 0; i < 3; i++) {
   for (j = 0; j < 3; j++) {   
      if (i == 1 && j == 1) {
         // we want to ignore and continue
      } else {
         // do work with these variables from inside the doWork function
         // (scoped to whatever scope `this` for loop is in)
         doWork.call(this, i, j); 
      }
   }
}
slickplaid
  • 1.4k
  • 1
  • 17
  • 21