Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / JavaScript

Function.length — function parameter count

A function's length property describes its parameter count according to declaration rules, not the number of arguments supplied when it is called.

Version: ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support

Syntax

fn.length
Function.length

fn.length reads a function's parameter count. The Function constructor is itself a function: Function.length is 1. This is a data property, not a method.

Only parameters before the first parameter with a default value count. Each destructuring pattern counts as one parameter; a rest parameter does not count. The standard length property is non-writable and non-enumerable, but configurable.

By contrast, arguments.length inside an ordinary function reports the number of arguments actually supplied in that call. That number can be greater or smaller than fn.length; do not confuse these two values.

Examples

function inspect({ value }, scale = 1, ...extra) {
  console.log(arguments.length);
}

console.log(Function.length);
console.log(inspect.length);
inspect({ value: 7 }, 2, 9);
console.log((({ x }, [y]) => {}).length);
console.log(((...items) => {}).length);

Result

1
1
3
2
0

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources