Standard built-ins

Function.length

Try the free JavaScript compiler

Number of formal parameters before the first default; rest is excluded and a destructuring pattern counts as one. Bound length is adjusted by leading arguments.

Formal Syntax & Structure

javascript syntaxjavascript
fn.length

Return Value

Number

Expected formal parameter count.

Working Example

Example Snippetjavascript
function f(a,b=0,...rest){} console.log(f.length);
JavaScript Reference