Chapter 9
Making the Rounds with Loops
In This Chapter
Considering the need for loops
Working with for loops
Working with while loops
Looping through objects
Creating nested loops
Repetitive actions appear everywhere in the real world, so they also appear in applications. For example, you don’t do a single pushup and stop — you do a number of pushups to achieve a specific fitness goal. You’d be really surprised if an application allowed you to select a single menu item, performed the required task, and then ended so that it couldn’t perform any other tasks. Applications repeatedly ask you to select menu or other options to complete a particular goal that consists of many individual tasks. Repetition also appears inside the application. An application downloads individual pieces of a graphic, one piece at a time, until all the pieces appear on the local computer and the application displays them onscreen.
JavaScript supports several kinds of loops: for
, while
, do...while
, and for...in ...
Get HTML5 Programming with JavaScript For Dummies now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.