Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
49
rated 0 times [  50] [ 1]  / answers: 1 / hits: 15973  / 13 Years ago, wed, august 3, 2011, 12:00:00

Is it possible to get all of the arguments a Javascript function is written to accept? (I know that all Javascript function arguments are optional)? If not, is it possible to get the number of arguments? For example, in PHP, one could use:



$class = new ReflectionClass('classNameHere');
$methods = $class->getMethods();
foreach ($methods as $method) {
print_r($method->getParameters());
}


... or something like that, I haven't touched PHP in a while so the example above may not be correct.



Thanks in advance!



EDIT: Unfortunately, I have to be able to get the arguments outside of the body of the function... Sorry for the lack of clarification, but thanks for the current answers!


More From » reflection

 Answers
14

Suppose your function name is foo




Is it possible to get all of the arguments a Javascript function is
written to accept?




arguments[0] to arguments[foo.length-1]




If not, is it possible to get the number of arguments?




foo.length would work


[#90855] Monday, August 1, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
dakotahs

Total Points: 605
Total Questions: 104
Total Answers: 113

Location: Hungary
Member since Wed, Nov 9, 2022
2 Years ago
;