JavaScript Function.prototype.length Property
The length property of a function is the number of parameters it declares, not counting rest parameters or those with default values.
Description
The length property gives the number of parameters a function expects. It counts parameters up to the first one with a default value, and ignores rest parameters. It doesn't tell you how many arguments were actually passed.
It's used by libraries that need to know how many arguments a function expects, for example to automatically curry functions, or by test frameworks that check whether a callback accepts a done parameter. Destructured parameters count as one each.
The number of arguments actually passed to a call is available inside the function as arguments.length, or from a rest parameter's length. Like name, the property is read-only.
Syntax
func.lengthValue
The number of parameters the function expects.
Example
Browser Support
The following information will show you the current browser support for the Function.prototype.length property. Hover over a browser icon to see the version that first introduced support for this property.
Desktop





Tablets & Mobile





