Skip to content

Latest commit

 

History

History
72 lines (57 loc) · 1.9 KB

File metadata and controls

72 lines (57 loc) · 1.9 KB
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
devlang-javascript
language-reference
length Property
JavaScript
TypeScript
DHTML
Length property
length property (function)
fdc8e1c9-0dac-4e1b-ba3a-11073c37ef63
15
mikejo5000
mikejo
ghogen

length Property (Function) (JavaScript)

Gets the number of arguments defined for a function.

Syntax

  
functionName.length  

Remarks

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.

Example

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  
  

Requirements

[!INCLUDEjsv2]

See Also

arguments Property (Function)
length Property (Array)
length Property (String)