Well, i understand my question is a little bit strange and the answer seems obvious ("it's impossible !"), but, as JS is a very open language, i go on anyway :)
Let's say, we have the following code :
function dummy() {
}
var obj = new dummy();
var result = obj.aFunction('a','b');
Obviously, the JS interpretor says :
obj.aFunction is not a function
I understand his anger :) but is there a trick to bypass the interpretor (or something like that) or to create on-the-fly the aFunction function into the obj object before the interpretor evaluates all the stuff ?
I've red all about using dynamic function names and so on (using eval() and other tricks) but that don't solve my (weird) problem ...
Thanks in advance.
EDIT : Well, folks, thanks for your answers, but it's not my problematic.
In fact, i used to code in Java with AOP and what i want is :
- Create a Valve (or something like this) that catches all the exceptions
- Analyse the exception
- if the exception corresponds to my 'no function' error, i create from scratch the function and execute it
- I garbage this exception
- if it's not the good exception i let it to continue its job
Unfortunatly, You cannot do that in JS. Using an ExceptionHandler is not sufficient because its API is too poor ...
But, Thanks to all ...