JS Built-ins
Functionlengthintermediate

Function.length β€” default parameters not counted

πŸ“– Usage Example
function fn(...args) {}
fn.length  // β†’ 0 (rest params not counted)

Rest parameters are not included in Function.length.

fn.length β€” defaults excluded

Parameters with default values are not counted in fn.length. Only the parameters before the first default are counted.

Challenge: Verify that function h(a, b = 1) {} has h.length === 1.

πŸ’‘ Hints (1)
  • β€’ Parameters with defaults do not count towards `fn.length`.