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

Chapter 7. Functions

Functions are an important and complex part of the JavaScript language. This chapter examines functions from several points of view. First, we discuss functions from the syntactic standpoint, explaining how they are defined and invoked. Second, we cover functions as a data type, with examples of the useful programming techniques that are made possible by treating functions as data. Finally, we consider the topic of variable scope within the body of a function and examine some of the useful function-related properties that are available to an executing function. This includes a discussion of how to write JavaScript functions that accept an arbitrary number of arguments.

This chapter focuses on defining and invoking user-defined JavaScript functions. It is also important to remember that JavaScript supports quite a few built-in functions, such as eval( ), parseInt( ), and the sort( ) method of the Array class. Client-side JavaScript defines others, such as document.write( ) and alert( ). Built-in functions in JavaScript can be used in exactly the same ways as user-defined functions. You can find more information about the built-in functions mentioned here in the core and client-side reference sections of this book.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


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