Whilst researching Magento 2's implementation of Knockout JS I keep coming across this._super();.

What does this do?


Searching the dev docs for this returns the uiClass library page which mentions the following:

The _super() method calls the parent UI component method with the same name as the _super() method’s caller; if that method does not exists in the parent UI component, then the method tries to find it higher in the inheritance chain.

The below example would call the parent methods initialize function.

initialize: function () {
    this._super(); //_super will call parent's `initialize` method here

    return this;
| improve this answer | |
  • 1
    Look up the prototype js library. That's what magento uses to implement this functionality. – Aaron Allen Oct 20 '16 at 12:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.