Returns the actual number of arguments passed to a function by the caller.
[function.]arguments.length
The optional function argument is the name of the currently executing Function object.
The length property of the arguments object is initialized by the scripting engine to the actual number of arguments passed to a Function object when execution begins in that function.
The following example illustrates the use of the length property of the arguments object. To fully understand the example, pass more arguments to the function than the 2 arguments expected:
function ArgTest(a, b){
var i, s = "The ArgTest function expected ";
var numargs = arguments.length
;
var expargs = ArgTest.length;
if (expargs < 2)
s += expargs + " argument. ";
else
s += expargs + " arguments. ";
if (numargs < 2)
s += numargs + " was passed.";
else
s += numargs + " were passed.";
return(s);
}
arguments Property | length Property (Array) | length Property (String)
Applies To: arguments Object | Function object