| title | ms.custom | ms.date | ms.prod | ms.reviewer | ms.suite | ms.technology | ms.tgt_pltfrm | ms.topic | f1_keywords | dev_langs | helpviewer_keywords | ms.assetid | caps.latest.revision | author | ms.author | manager | |||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
length Property (Function) (JavaScript) | Microsoft Docs |
01/18/2017 |
windows-client-threshold |
|
language-reference |
|
|
|
fdc8e1c9-0dac-4e1b-ba3a-11073c37ef63 |
15 |
mikejo5000 |
mikejo |
ghogen |
Gets the number of arguments defined for a function.
functionName.length
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;
return s;
}
document.write(ArgTest(1, 2));
// Output:
// Expected Arguments: 2
// Passed Arguments: 2
[!INCLUDEjsv2]
arguments Property (Function)
length Property (Array)
length Property (String)