length
Summary
Gets the number of arguments defined for a function.
Syntax
functionName.length
Examples
The following example illustrates the use of the length property:
function ArgTest(a, b){
var s = "";
s += "Expected Arguments: " + ArgTest.length;
s += "<br />";
s += "Passed Arguments: " + arguments.length;
return s;
}
document.write(ArgTest(1, 2));
// Output:
// Expected Arguments: 2
// Passed Arguments: 2
Remarks
The required functionName is the name of the function.
The length property of a function is initialized by the scripting engine to the number of arguments in the function’s definition when an instance of the function is created.
What happens when a function is called with a number of arguments different from the value of its length property depends on the function.
See also
Other articles
Attributions
Microsoft Developer Network: Article