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

Chapter 7. Controlling Your Code II: Loo... > What Is Looping and Why Does Your Co...

What Is Looping and Why Does Your Code Need It?

There are some who would say that the only real goal of the programmer should be to get the job done. As long as the code produces the correct result or performs the correct tasks in the correct order, everything else is superfluous. Perhaps, but real programmers know that the true goal of programming is not only to get the job done, but to get it done as efficiently as possible. Efficient scripts run faster, take less time to code, and are usually (not always, but usually) easier to read and troubleshoot.

As you saw in Chapter 4, "Working with Functions," one of the best ways to introduce efficiency into your coding is to divide up your JavaScript chores and place them in separate functions. That way, you only need to write the code once and then call it any time you need it. This is known in the trade as modular programming, and it saves time and effort by helping you avoid reinventing too many wheels.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


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