Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
314 Chapter 9 JavaScript: Functions Summary Section 9.1 Introduction ยท The best way to develop and maintain a large program is to construct it from small, simple pieces, or modules (p. 279). This technique is called divide and conquer (p. 279). Section 9.2 Program Modules in JavaScript ยท JavaScript programs are written by combining new functions (p. 279) that the programmer writes with "prepackaged" functions and objects available in JavaScript. ยท The term method (p. 279) implies that the function belongs to a particular object. We refer to functions that belong to a particular JavaScript object as methods; all others are referred to as functions. ยท JavaScript provides several objects that have a rich collection of methods for performing common mathematical calculations, string manipulations, date and time manipulations, and manipula- tions of collections of data called arrays. These objects make your job easier, because they provide many of the capabilities programmers frequently need. ยท You can define functions that perform specific tasks and use them at many points in a script. These functions are referred to as programmer-defined functions (p. 279). The actual statements defining the function are written only once and are hidden from other functions. ยท Functions are invoked (p. 280) by writing the name of the function, followed by a left parenthesis,