Returns the actual number of arguments passed to a function by the caller.
[function.]arguments.length |
Remarks
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.
Example
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:
Copy Code | |
---|---|
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); } |