JAVASCRIPT

 Home  Computers & Internet  Web Programming JAVASCRIPT
What is Javascript?
Javascript Placement
Syntax
Reserved Words
Variables
Data Types
Escaping Characters
Concatenation
Arithmetic Operators
Assignment Operators
Comparison Operators
Boolean Operators
Conditional Operator
If Statements
Else If Statements
If Else Statements
Switch Statements
While Loops
For Loops
Do While Loops
Break Statement
Continue Statement
prompt()
alert()
Date()
Event Handlers
String Object Methods
Math Object Methods
Window Object Methods

JAVASCRIPT BREAK STATEMENT

In javascript programming, the break word is used to terminate the further execution of a loop if a certain test condition is met.

The break word is situated in the loop after a condition. As soon the test condition is met, the loop stops immediately.

Example Without Break:

i=1;

while(i < 10)
{
document.write("Hello<br>");
i++;
}

The above will output Hello nine times and the loop ends naturally.

Example With Break:

i=1;

while(i < 10)
{
document.write("Hello<br>");
if(i== 4)
break;
i++;
}

The above will output Hello four times and the loop ends prematurely when the test condition of i==4 is met.

Home | Privacy Policy | Terms Of Use | Contact Us