Reprint: http://msdn.microsoft.com/zh-cn/library/4cz6db7d (v=vs.94). aspx
Gets the number of parameters defined for a function.
Functionname.length
Note
The necessary functionname is the name of the function.
When an instance of a function is created, the script engine initializes the function's length property to the number of arguments in the function definition.
When a function is called, if the number of its arguments differs from the value of its length property, the situation depends on the function.
Example
The following example illustrates the use of the length property:
1 functionArgtest (A, b) {2 vars = "";3 4s + = "expected Arguments:" +argtest.length;5s + = "<br/>";6s + = "Passed Arguments:" +arguments.length;7 8 returns;9 }Ten Onedocument.write (Argtest (1, 2)); A - //Output: - //expected Arguments:2 the //Passed Arguments:2
Requirements
Supported in the following document modes: Quirks, Internet Explorer 6 standard mode, Internet Explorer 7 Standard mode, Internet Explorer 8 standard mode, Internet Explorer 9 standard mode, INT Ernet Explorer 10 Standard mode and Internet Explorer 11 standard mode. In addition, it is also supported in store apps (Windows 8 and Windows Phone 8.1).
Length Property (Function) (JavaScript)