Javascript break Statement break out of for loop

Introduction

Using the break statement in a for statement.

for ( let count = 1; count <= 10; ++count )
{
   if ( count == 5 )
      break;//from  ww  w. j  a v a 2  s  . c om

   console.log( "Count is: " + count + "<br />" );
}

console.log( "Broke out of loop at count = " + count );



PreviousNext

Related