Breaking and continuing

Estimated reading: 1 minute 21 views

Stopping a loop

				
					 for (var i = 0; i < 10; i++) {
 if (something) {
 break;
 }
 }
				
			

Skipping to the next iteration of a loop

				
					 for (var i = 0; i < 10; i++) {
 if (something) {
 continue;
 }
 // The following statement will only be executed
 // if the conditional ’something’ has not been met
 console.log(’I have been reached’);
 }
				
			
Share this Doc

Breaking and continuing

Or copy link