JavaScript never complains about the number of arguments. Call a function of three parameters with one, and the other two are undefined; call it with ten, and seven are quietly ignored. Two numbers tell you what happened: how many parameters the function declares, and how many arguments a call received. Libraries that curry functions, check calls or route events by how many arguments a handler takes read both.
functioncountArguments() // returns a numberfunctioncountParameters(fn) // returns a numberfunctionrequireArguments(fn) // returns a function
countArguments(...): returns how many arguments the call received.
countParameters(fn): returns how many arguments fn expects, as the language counts them: the parameters before the first one with a default value, with a rest parameter never counted.
requireArguments(fn): returns a function that throws a TypeError when it receives fewer arguments than fn expects, and otherwise calls fn with its this and every argument and returns the result.
countArguments counts every argument passed, including an explicit undefined and the holes of a spread array, however many there are.
countParameters counts the parameters before the first default value, ignores a rest parameter, counts a destructured parameter as one, and works for arrow functions, classes and bound functions.
The function from requireArguments throws a TypeError without calling fn when it gets too few arguments; an explicit undefined counts as an argument.
With enough arguments (more is fine), it calls fn with its own this and every argument, and returns fn's result.
It expects the same number of arguments as fn: its own length matches.