JS Built-ins
Functionlengthbeginner

Function.length β€” three parameters

πŸ“– Usage Example
function fn(a, b, c) {}
fn.length  // β†’ 3

Function.length returns the number of declared parameters.

fn.length

The length property of a function returns the number of formal parameters it expects (excluding rest parameters and defaults).

Challenge: Verify that function f(a, b, c) {} has f.length === 3.

πŸ’‘ Hints (1)
  • β€’ `fn.length` counts only the positional parameters before any defaults or rest.