Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

4
  • 1
    This is unnecessarily complicated. At the very least you could write this.callback = function() { parent.callbackFunctionOfParent() } but I'm sure this could be simplified a lot more depending on what you are actually trying to achieve. Commented May 10, 2023 at 15:53
  • The question was about accessing 'this' in the context of the derived class, not what is the simplest way to call a function on the parent class. Commented May 11, 2023 at 18:33
  • 1
    But why would you present a solution that is more difficult to understand? Solutions should be reduced to the absolute minimum so that they are easy to understand. According to your argument I could provide the following solution to the question "how to add two numbers" and it would be ok? function mul(x, y) { return x * y; } function add(x, y) { return mul(x, 1) + mul(y, 1); }; add(41, 1) Commented May 12, 2023 at 11:36
  • I think you are free to edit the post and make it more terse, if it is still understandable and gives the same result on "run code snippet", then I have no problem with this. Commented May 15, 2023 at 15:50