Tech Study

JavaScript break statement

The break statement is a control flow statement used in JavaScript to exit a loop, switch statement, or labelled block. The break statement completely exits a while or for loop.

You can use the break statement in a loop to prematurely terminate the loop under certain conditions. For example, in a for loop, you can use the break statement to exit the loop when certain conditions are met.

The break statement can also be used with a label to exit nested loops.

Syntax:

break;

Example:

variable number = 7;

var number = 7;

for(var counter=0; counter < 100 ; counter++)

 {

 if(number === counter) 

{

   console.log('number found ', number);

   break;

 }

 console.log('Counter is ', counter);

}

Output:

Counter is  0

Counter is  1

Counter is  2

Counter is  3

Counter is  4

Counter is  5

Counter is  6

counter is 7

Number found 7

Java Final keyword

Introduction : java final keyword The final keyword present in Java programming language is generally used for restricting the user. …

Read more

C++ Memory Management: new and delete

C++ Memory Management We know that arrays store contiguous and the same type of memory blocks, so memory is allocated …

Read more