Chapter 4. Functions: code on demand

This chapter covers

  • Organizing instructions with functions
  • Defining a function—specifying code to be executed on demand
  • Calling a function—executing code on demand
  • Reducing repetition in code
  • Making programs easier to read and update

One of the main themes of Get Programming with JavaScript is managing complexity through good organization. In chapter 2, you stored information in variables and saw how choosing good names for those variables helps you understand their purpose in a program. In chapter 3, you grouped variables as properties of objects. You can focus on objects as a whole or drill down into the details when needed. In this chapter you take a look at another important method for organizing ...

Get Get Programming with JavaScript 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.