function (statement)

Declares a function with the specified parameters. Acceptable parameters include strings, numbers, and objects.

Syntax

function name( [param] [, param] [..., param] )
{
statements
}

Parameters

Parameter Description
name The function name.
param The name of an argument to be passed to the function. A function can have up to 255 arguments.
statements The statements which comprise the body of the function.

Description

To return a value, the function must have a return statement that specifies the value to return.
A function created with the function statement is a Function object and has all the properties, methods, and behavior of Function objects.

Examples

The following code declares a function that returns the total dollar amount of sales, when given the number of units sold of products a, b, and c.

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.