Function.arguments

An array corresponding to the arguments passed to a function.

Local variable of All function objects
Property of Function (deprecated)

Description

The arguments array is a local variable available within all function objects; arguments as a property of Function is no longer used.
You can refer to a function's arguments within the function by using the arguments array. This array contains an entry for each argument passed to the function. For example, if a function is passed three arguments, you can refer to the arguments as follows:

arguments[0]
arguments[1]
arguments[2]

The arguments array is available only within a function body. Attempting to access the arguments array outside a function declaration results in an error.
You can use the arguments array if you call a function with more arguments than it is formally declared to accept. This technique is useful for functions that can be passed a variable number of arguments. You can use arguments.length to determine the number of arguments passed to the function, and then process each argument by using the arguments array. (To determine the number of arguments declared when a function was defined, use the Function.length property.)
The arguments array has the following properties:

Property Description
Function.arguments.callee Specifies the function body of the currently executing function.
Function.arguments.caller Specifies the name of the function that invoked the currently executing function. (Deprecated)
Function.arguments.length Specifies the number of arguments passed to the function.

Examples

Example 1. This example defines a function that concatenates several strings. The only formal argument for the function is a string that specifies the characters that separate the items to concatenate. The function is defined as follows:

You can pass any number of arguments to this function, and it creates a list using each argument as an item in the list.

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