0

I am building an API using google closure.

I want to access a method of a superclass A, from within a method with the same name from the child class B.

Please, see the following pseudo-code:

Superclass A

class A {
    move: function() { ... }
}

Child class B

class B extends A {
    // B has its own 'move' method which uses the 'move' method from A
    move: function() {
        parentClass_.move();
    }
}

I read somewhere that the keyword 'parentClass' does this. I read here that it is the keyword 'superClass_' who does this.

None of them work. Maybe I am doing it wrong.

Would someone please help me?

Thanks.

João

joaorodr84
  • 1,251
  • 2
  • 14
  • 33

1 Answers1

0

This depends on how the class is defined. The syntax you use in your question doesn't match anything I know.

Ultimately, you need a reference to the super class, and the value must be defined in a way such that the subtype definition doesn't overwrite it. Typically, this is done with the prototype object (but there are other way), in which case you can do:

A.prototype.move.call(this)

If this is Closure Library code, you can use:

B.base(this, 'move');
John
  • 5,443
  • 15
  • 21