Thoran Thoran - 7 months ago 11
Javascript Question

Could "super" be used inside a method of subclass to call the corresponding method of super-class without direct referencing?

I came across a usage of "super" in a tutorial that seemed strange.

super()
is used inside the method
get()
of the subclass to call the method
get()
of the superclass without using any accessor notations. Would that work? If yes, where can I find more references about it?

Answer

No, direct super calls (without a property) are only allowed in constructors, and constitute syntax errors everywhere else. It needs to be super.get().