I want to get the name of the current method from within an instance method of a class in Typescript.
(Pseudocode, doesn't work):
class Foo {
bar() {
console.log(something); //what should something be?
}
}
new Foo().bar();
I expect 'something' to return 'bar'. I realize that this can give me the class, and I could somehow get the class and its attributes from it, but I do not know how to get 'this function' (i.e, the method bar, not the class Foo).
I have seen several other questions related to finding the class name, etc. but not one that addresses getting the current method name.
getFoo()andgetBar(), and I want to handle all these using agetObject(objName)function that parses the function name, and returns the object from a dictionary, by name. I want to callgetObject(thisFuncName)in every such function rather than having to change each such function to say things likegetObject('foo'), etc..