Using "super" in the object literals

The super keyword can also be used in the concise methods of the object literals. The super keyword in concise methods of the object literals, has the same value as the [[prototype]] property of the object defined by the object literal.

In the object literals, super is used to access the over-ridden properties by the child object.

Here is an example to demonstrate how to use super in object literals:

var obj1 = {
  print(){
    console.log("Hello");
  }
}

var obj2 = {
  print(){
    super.print();
  }
}

Object.setPrototypeOf(obj2, obj1);
obj2.print(); //Output "Hello"
Using "super" in the object literals
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.27.99