Chapter 9

Making the Rounds with Loops

In This Chapter

arrow Considering the need for loops

arrow Working with for loops

arrow Working with while loops

arrow Looping through objects

arrow 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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.