www.pickatutorial.com Computer Tutorials
Top eBooks: C/C++ | C# | Android | Mathematics | Database | Cloud | Graphics | Networking | Oracle | Hardware | AI
Top Tutorials: C/C++ | C#.NET | PHP MySQL | Java | Java Script | jQuery | HTML | xHTML | HTML5 | VB Script| CSS
Lessons JavaScript while Loop Bookmark and Share
Tutorial Home
Lesson 1
Lesson 2
Lesson 3
Lesson 4
Lesson 5
Lesson 6
Lesson 7
Lesson 8
Lesson 9
Lesson 10
Lesson 11
Lesson 12
Lesson 13
Lesson 14
Lesson 15
Lesson 16
Lesson 17
Lesson 18
Lesson 19
Lesson 20
Lesson 21
Lesson 22
Lesson 23
Lesson 24
Lesson 25
Lesson 26
Lesson 27
Lesson 28
Lesson 29
Lesson 30
Lesson 31
Lesson 32
Lesson 33
Lesson 34
Lesson 35
Lesson 36
Lesson 37
Lesson 38
Lesson 39
Lesson 40
Lesson 41
Lesson 42
Lesson 43
Lesson 44
Lesson 45
Lesson 46
Lesson 47
Lesson 48
Lesson 49

In the previous lesson we learned for loop. In this lesson we will be discussing another looping construct of JavaScript i.e. while loop.

The while loop, just like the for loop, allows us to execute some piece of code a specified number of times until the loop condition remains true.

A while keeps repeatedly executing itself as long as the loop condition is true. Basic syntax of a while loop follows:

while (condition) {
// code to be executed
}

When the execution reaches the while statement it checks the condition and if it evaluates to true the body of the while loop is executed. On every iteration of the loop the condition is checked before the executio of the loop body. This process continues untill the condition evaluates to false..

The following while loop iterates as long as i is less than 6:

i = 0;
while ( i< 6 )
{
// code to be executedd
n++;
}


Next >>> Lesson No. 13: JavaScript do...while Loop





Home - Advertise - Contact - Disclaimer - About Us
© Since 2006 pickatutorial.com -- All Rights Reserved.