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

Functions

Before you get into the next example, you need to learn about functions, which you'll use often when writing JavaScript. A function is a set of JavaScript statements that performs a task. Every function must be given a name, and can be invoked, or called, by other parts of the script.

Functions can be called as many times as needed during the running of the script. For example, let's say that you've gotten some information that a user typed into a form and you've saved it using JavaScript (there's more about this sort of thing in Chapter 6, "Validating Forms" ). If you need to use that information again and again, you could repeat the same code over and over in your script. But it's better to write that code once as a function, then call the function whenever you need it.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


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