Favorites

JavaScript Function.prototype.length Property

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
Function.prototype.length
JavaScript Function Instance propertyThis property is supported by all modern browsers.
Updated 28th November 2026

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.length

Value

The number of parameters the function expects.

Example

console.log(((a, b) => {}).length);
console.log(((a, b = 2) => {}).length);
console.log(((...args) => {}).length);

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.

This property is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee