Is it possible to annotate JavaScript function parameters as can be done with attributes in C#?
Example (C#):
public void DoSomething([RequiredAction(Action="some_action")] Client client) {
// ...
}
The aim is - given a function - use reflection to inspect for instance the "type" of the parameters and perform the necessary conversions before calling it.
One can of course use this answer and annotate the parameters by using specific parameter prefixes. For instance the Hungarian notation where sParam would identify the parameter should be a string. But that's not really convenient nor that extensible since it requires to specify names. Is there a more generic way to achieve this?
Aucun commentaire:
Enregistrer un commentaire