JavaScript Break and Continue

 

 

Use break statement  to jump out of a loop:

 

for (let i = 0; i < 10; i++) {

//code

//break
 if (i === 3)  break; 

}

 

The continue statement breaks one iteration (in the loop), if a specified condition occurs, and continues with the next iteration in the loop.

 

 

for (let i = 0; i < 10; i++) {
	//code
	
	//continue
  if (i === 3) continue; 
}

Tags:

Share:

Related posts