So I would like to call an es 6 static class method By reflection using a string className and a string method name. I have tried several ways. unfortunately I don’t seem to find the correct way to do this.
Can anybody help?
class a{
static b(nr){
alert('and the answer is' + nr)
}
}
let aClassName = 'a',
aMethodeName = 'b',
theCompleteCall = 'a.b',
anArgument = 42;
//Reflect.apply(theCompleteCall,anArgument);
//window[aClassName][aMethodeName](anArgument);
//window[theCompleteCall](anArgument);
Aucun commentaire:
Enregistrer un commentaire