Like most languages, there's more than one way to do it (TMTOWTDI).
function foo(a,b,c){
//...
}
Length method of Function object:
foo.length(); // returns 3
Parse it (using test):
args = foo.toString();
RegExp.lastIndex = -1; // reset the RegExp object
/^function [a-zA-Z0-9]+\((.*?)\)/.test(args); // get the arguments
args = (RegExp.$1).split(', '); // build array: = ["a","b","c"]
This gives you the ability to use args.length, and list the actual argument names used in the function definition.
Parse it (using replace):
args = foo.toString();
args = args.split('\n').join('');
args = args.replace(/^function [a-zA-Z0-9]+\((.*?)\).*/,'$1')
.split(', ');
Note: This is a basic example. The regex should be improved if you wish to use this for broader use. Above, function names must be only letters and numbers (not internationalized) and arguments can't contain any parentheses.