Parameter Passing

One of the most powerful features in a modern programming language is the ability for programmers to create their own functions and to make them as flexible as possible. One of the ways to make functions flexible is to use parameters and parameter passing. Before we look at the advantages that can be gained using parameter passing we will look at some examples of the different ways that parameters can be passed to programs.

So far we have already encountered parameter passing within JavaScript, for example, the alert command is made flexible because it can be given different textual information to display on the screen, such as ‘Hello’ or ‘Goodbye’. The prompt command also makes use of this similar facility by allowing different textual messages to be passed to it.

Next: Example Program 1