Loops


Loops

In JavaScript, loops enable you to execute a series of statements over and over on your data. At first, that might not seem very excitingwhat's the good of executing the same code on your data more than once? However, each time through the loop, the data can be differentfor example, imagine that you have 10,000 students at a university and you need to calculate their average final grade using the values in a JavaScript array. Adding those grades by hand to find the average grade would be a big and bothersome taskbut using a loop, you can just loop over all members of the array with a few simple statements. No problem!

Several kinds of loops are available in JavaScriptthe for loop, the for in loop, the while loop, and the do while loop. And we'll see them all here.



Inside Javascript
Inside JavaScript
ISBN: 0735712859
EAN: 2147483647
Year: 2005
Pages: 492
Authors: Steve Holzner

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net