• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

Using JavaScript Statements

In addition to objects, JavaScript has commands that do things such as control program flow. This section examines multiple statements that control how your JavaScript application runs. This section is where JavaScript really shows its C roots—the statements and operators covered in the following pages are nearly identical to those found in the C programming language.

Using Loops

There are several different ways to perform loops (or iterations) in JavaScript: the for loop, the for-in loop, and the while loop. There are significant differences between these loops and, depending on your application, one may be more appropriate than another. For instance, suppose you want to perform an action for a predetermined number of times. You could use a for loop to accomplish this task.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint