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

C String Functions

C String Functions perform certain operations, It provides many useful string functions which can come into action. The <string.h> header …

Read more

Function Pointer in C++

Introduction : Function Pointer in C++ Pointers: In function pointer in c++ are the variables that consist of addresses of …

Read more