Suppose you want to add a method f() to an object myObj where f() uses the super keyword in its body. Eg:

function f() {
    return super.foo() + 10
}

myObj.foo = f

Well, this doesn't work, because f() can't be declared (since super isn't bound to anything).

Is there a way to dynamically add a method to an object when the method uses the super keyword in the method body?

0

There are 0 best solutions below