Bagikan melalui


length Property (Function)

Returns the number of arguments defined for a function.

function.length

Arguments

  • function
    Required. The name of the currently executing Function object.

Remarks

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.

Example

The following example illustrates the use of the length property:

function ArgTest(a, b)
{
    var s = "Expected Arguments: " + ArgTest.length;
    return (s);
}

Requirements

Version 2

Applies To:

Function Object

See Also

Reference

arguments Property

length Property (Array)

length Property (String)

Change History

Date

History

Reason

July 2009

Modified example.

Content bug fix.