Can someone help me on how to get function parameter names? For instance:
var A = function(a, b, c) {};
I need to get the parameter names outside the function that a , b and c (as literally as strings, for example, to put into the array [" a ", " b ", " c "]), so I can check not only the properties of the object / class in the class with respect to the interface, as well as parameters.
Before this question starts the confusion, let me explain about the implementation of the interface in my term and the reason why I need the answer to the question above:
First of all, I found one interesting way that I would like to use in implementing the Glen Ford interface in JavaScript:
for (var member in theInterface) { if ( (typeof theObject[member] != typeof theInterface[member]) ) { alert("object failed to implement interface member " + member); return false; } }
(See implementation details 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 checks the properties of the object (variables and methods), which is not enough for me.
I need more verification at the parameter level, so that code that implements one interface must follow the methods of the interface, and also follow the parameters from the methods of the interface.
PS. Please do not argue about why to use the interface or why it is useless or useful; instead, it is most useful if you can provide a better interface implementation. The focus here is on what I need to know how to get function parameter names.
user905864
source share