0

I have a class lets say a test1 that has static methods #a and #b and is called from a public method lets say message(methodName) that has the argument, methodName (either a or b) that decided which method to call. If a and be were not static, I could do this

class test1 {
    message(methodName) {
    this[methodName]
    }
    a() {
    }
    b() {
    }
}

but because they are static, I wanted to do,

    class test1 {
    message(methodName) {
    this["#"+methodName]
    }
    #a() {
    }
    #b() {
    }
}

But it does not work. Am i doing something wrong or is there some other way??

2
  • 4
    # does not mean "static". It means private Commented Oct 20, 2023 at 10:14
  • If you actually wanted static, then see stackoverflow.com/questions/28627908/… Commented Oct 20, 2023 at 10:18

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.