get function arguments count from external scope

javascript

Solution

You want `Function.length`:

function test(a, b, c) {
  // code
}

console.log(test.length); // 3

BTW, the number of expected arguments of a function is called the arity. There used to be a method called `Function.arity` but was deprecated in favour of `Function.length`.

Problem

Is it possible to get function arguments count from external scope? ``` var foo = function(a,b,c) { } alert(foo.arguments.length); // how to do it? possible? ```

Original source