Javascript break Statement Labeled break Statement

Introduction

Labeled break statement in a nested for statement.

stop: { // labeled block 
   for ( let row = 1; row <= 10; ++row )
   {/*from   w w  w.  j  a  v a 2 s. c  om*/
      for ( let column = 1; column <= 5 ; ++column )
      {
         if ( row == 5 )
            break stop; // jump to end of stop block                     

         console.log( "*" );
      } //end for

      console.log( "\n" );
   } //end for
   // the following line is skipped
   console.log( "This line should not print" );
}



PreviousNext

Related