Using super in object literals
The super keyword can also be used in concise methods of 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 object literals, super is used to access overridden properties by the child object.
Here is an example to demonstrate how to use super in object literals:
const obj1 = { print() { console.log("Hello"); } } const obj2 = { print() { super.print(); } } Object.setPrototypeOf(obj2, obj1); obj2.print(); //Output "Hello"
Note
ES.next proposal includes adding support for truly private properties in classes using the hash (#) symbol. #myProp inside a class will be private to that class.