can anyone help me on how to retrieve function parameter names? For example:
var A = function(a, b, c) {};
I need to get the parameter names outside the function, which is a, b, and c (as in literally as strings, such as to be put in an array ["a", "b", "c"]), so I can validate not only object/class properties in a class towards an interface, but also the parameters.
Before this question starts raising confusion, let me explain about interface implementation in my term and the reason why I need the answer of the question above:
First of all, I found one interesting way I would like to use in implementing interface by Glen Ford in JavaScript:
for (var member in theInterface) {
if ( (typeof theObject[member] != typeof theInterface[member]) ) {
alert("object failed to implement interface member " + member);
return false;
}
}
(Please see the detail about the implementation from http://knol.google.com/k/programming-to-the-interface-in-javascript-yes-it-can-be-done-er-i-mean-faked#).
However, the implementation above only validates the object properties (variable and methods) only, which is not enough for me.
I need more validation to parameter level, so that the code that implements one interface should follow the interface methods and also follow the parameters from the interface methods as well.
PS. Please don't argue about why use interface or why it's useless or useful; instead it's most useful if you can provide better interface implementation. The focus here is I just need to know how to get function parameter names.