• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 3. The JavaScript Language: Loop... > Getting More Control: Ending and Con...

Getting More Control: Ending and Continuing Loops

You actually have more control over loops than is apparent in the for, while, and other statements we’ve already seen. JavaScript also enables you to end a loop partway through using the break statement, and skip on to the next iteration using the continue statement. Those statements are coming up next.

Ending a Loop Early

Sometimes, you might want to end a loop early—for instance, when you’ve found the data for which you were searching an array. To end loops early, you can use the break statement. Here’s the syntax of this statement:


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


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