O'Reilly logo

HTML5 Programming with JavaScript For Dummies by John Paul Mueller

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 7

Using Functions

In This Chapter

arrow Working with built-in functions

arrow Using the Math object functions

arrow Creating your own functions

arrow 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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required