How to break a loop JavaScript

{0 Comments}

To break a loop in JavaScript we can use break statement to break a loop, you have to write break with “;” this will break the excising loop of JavaScript you can use same in while and for loop to. like in following example

 Javascript |  copy code |? 
1
   for (i=0;i<10;i++)
2
  {
3
  if (i==3)
4
    {
5
    break;
6
    } 
7
do some thing here 
8
 }
9

Leave a Comment

Your email address will not be published.