The Function arguments is deprecated in Javascript 1.5.
The arguments property consists of an array of all the arguments passed to a function.
The arguments property consists of an array of all the arguments passed to a function. The arguments property is only available inside a function, but can be used to refer to any of the function's arguments by stating the appropriate element of the array. For example; arguments[0]; newFunction.arguments[1] etc. (Note that the arguments property can be preceeded by the function name). The arguments array is especially useful with functions that can be called with a variable number of arguments, or with more arguments than they were formally declared to accept.
function calcAverage()
{
var sum = 0
for(var i=0; i<arguments.length; i++)
sum = sum + arguments[i]
var average = sum/arguments.length
return average
}
document.write("Average = " + calcAverage(400, 600, 83))
Average = 361
In this example, a function is declared to calculate the average of a variable number of numbers (which are the function's arguments). By using the arguments array and the arguments.length property, you can pass the function any number of arguments and have it return the average of them.
Syntax: [Function.]arguments.callee
The arguments.callee property can only be used within the body of a function and returns a string specifying what that function is. As the this keyword doesn't refer to the current function, you can use the arguments.callee property instead.
The arguments.caller property is deprecated in JavaScript 1.3 and is no longer used, but where it is, it specifies the name of the function that called the currently executing function.
Syntax: Function.]arguments.length
The arguments.length property returns the number of arguments passed to a function, as opposed to the function.length property, which returns the number of arguments that a function expects to receive.