Hướng dẫn super in javascript
The super keyword is used to access properties on an object literal or class's [[Prototype]], or invoke a superclass's constructor. The DescriptionThe Note:
In the constructor body of a derived
class (with The "property lookup" form can be used to access methods and properties of an object literal's or class's [[Prototype]]. Within a class's body,
the reference of Note that the reference of When setting properties through ExamplesUsing super in classesThis code
snippet is taken from the classes sample (live demo). Here
Super-calling static methodsYou are also able to call super on static methods.
Accessing super in class field declaration
Note that instance fields are set on the instance instead of the constructor's
Here, Deleting super properties will throw an error You cannot use the
delete operator and
Using super.prop in object literalsSuper can also be used in the object initializer / literal notation. In this example, two objects define a method. In the
second object,
Methods that read super.prop do not behave differently when bound to other objectsAccessing
The same happens in object literals.
Only resetting the entire inheritance chain will change the reference of
Setting super.prop will set the property on this insteadSetting properties of
This means that while methods that get
However,
Specifications
Browser compatibilityBCD tables only load in the browser See also |