This documentation is archived and is not being maintained.

length Property (Function) 

Returns the number of arguments defined for a function.


function.length

function

Required. The name of the currently executing Function object.

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) : String {
   var s : String = "The argTest function expected " ;
   var expargs : int = argTest.length;
   s += expargs;
   if (expargs < 2)
      s += " argument.";
   else
      s += " arguments.";
   return(s);
}
// Display the function output.
print(argTest(42,"Hello"));

The output of this program is:

The argTest function expected 2 arguments.
Show: