Get number of arguments in function expression?

javascript

Solution

javascript functions have a .length property

https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Function/length

Problem

Possible Duplicate: Get a function’s arity How can I declare a function expression, pass it into a defined function, and have the defined function determine how many arguments the function expression has? See this code snippet for reference: ``` function getArgumentCount(fexp) { return ...; } var fexp1 = function(a) { }; var fexp2 = function(a, b) { }; console.log(getArgumentCount(fexp1)); // Should output 1 console.log(getArgumentCount(fexp2)); // Should output 2 ```

Original source

Related problems