Export (0) Print
Expand All
0 out of 2 rated this helpful - Rate this topic

length Property (Function) (JavaScript)

Returns the number of arguments defined for a function.


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.

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;

   document.write (s);

Supported in the following document modes: Quirks, Internet Explorer 6 standards, Internet Explorer 7 standards, Internet Explorer 8 standards, Internet Explorer 9 standards. See Version Information.

Applies To: Function Object (JavaScript)

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
© 2014 Microsoft. All rights reserved.