Friday 10, February 2012
Welcome Guest, Register | Login  
      Home    |    Tutorials    |    Free Ebooks    |    Free Scripts    |    Articles    |    Blog     |    Forum    |    About Us    |    Contact Us

while Loop

while and do-while Loops
Two additional repeat loops are available in JavaScript. The while loop tests the supplied condition and continues to execute until it is met. Here is the syntax for it.
Syntax:
 while (condition){
    statement(s)
    }

Example:



var i=0;
while (i<=10)
{
document.write("The number is " + i);
document.write("
");
i=i+1;
}


Result:
The number is 0
The number is 1
The number is 2
The number is 3
The number is 4
The number is 5
The number is 6
The number is 7
The number is 8
The number is 9
The number is 10

Do-while loop:
The primary difference between these while and do-while loop is that the "do-while loop" will always execute one time whether the condition is true or not whereas the "while loop" will only execute if the condition is true.

Syntax:
 do{
    statements
    } while (condition)

Example:



var i=0;
do
{
document.write("The number is " + i);
document.write("
");
i=i+1;
}
while (i<0);


Result:
The number is 0

 
     
   
JavaScript Tutorial
 
  Introduction
Introduction
  Object Oriented Programming
Object Oriented Programming
  How to
How to
  Where use JavaScript
Where use JavaScript
  Variables
Variables
  Operators
Operators
  if Statement
if Statement
  Switch Statement
Switch Statement
  Functions
Functions
  for Loop
for Loop
  while Loop
while Loop
  Popup Boxes
Popup Boxes
  break and continue Statements
break and continue Statements
  Events
Events
  Date and Time Object
Date and Time Object
  Special Characters
Special Characters
 
 
 
Web Designing Tutorials
  HTML Tutorial
HTML Tutorial
  DHTML Tutorial
DHTML  Tutorial
  CSS Tutorial
CSS Tutorial
  XHTML Tutorial
XHTML Tutorial
 
Programming Languages Tutorials
  C Language Tutorial
C Language Tutorial
  C++ Tutorial
C++ Tutorial
  Java Language Tutorial
Java Language Tutorial
  Data Structure Theory Tutorial
Data Structure Theory Tutorial
 
Server Side Scripting Tutorials
  PHP Tutorial
PHP Tutorial
  SQL Tutorial
SQL Tutorial
  ASP Tutorial
ASP Tutorial
 
Client Side Scripting Tutorials
  JavaScript Tutorial
JavaScript Tutorial
  VBScript Tutorial
VBScript Tutorial
 
 
 
POPULAR E-BOOKS
 
Download  Squeeze Page Secrets Ebook Squeeze Page Secrets
   
Download Viral Marketing Secrets Ebook Viral Marketing Secrets
   
Download How To Really Earn Big With Your Own Internet Business  Ebook How To Really Earn Big With Your Own Internet Business
   
Download Ajax Design Patterns  Ebook Ajax Design Patterns
   
Download Giveaway Events Exposed Ebook Giveaway Events Exposed
   
 
Studiesinn.com © 2012 All Rights Reserved.
Website Designed & Developed by TechXprtz