Chapter 7
Using Functions
In This Chapter
Working with built-in functions
Using the Math object functions
Creating your own functions
Understanding how to create private data
In previous chapters, you see a multitude of both built-in and custom functions, but you don't really work through all of the intricacies of functions. In addition, JavaScript offers far more in the way of functions than the few you see in earlier chapters. This chapter focuses on the JavaScript function. It begins by introducing you to more built-in functions, especially those provided by the Math
object. After that, you begin creating your own custom functions.
This chapter introduces you to some new concepts when it comes to functions. For example, you discover the best time to separate code into a new function rather than keeping it part of an existing function. You also find some techniques for passing both required and optional parameters (arguments) to functions and returning data to the caller.
Perhaps the most controversial topic in the chapter is using private data with JavaScript. Some developers ...
Get HTML5 Programming with JavaScript For Dummies 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.