JavaScript·Advanced·Coding·1 min read
What problems do default and rest parameters cause for generic curry helpers?
Short interview answer
Function.length stops before the first default parameter and excludes rest parameters, so it may not represent the intended arity. Production helpers often require explicit arity or define clear limitations.
Example
((a, b, c) => 0).length; // 3((a, b = 1, c) => 0).length; // 1 — stops at the first default((...xs) => 0).length; // 0 — rest params don't countKey takeaway
Explain the underlying mental model clearly, then support it with a concrete example and its trade-offs.