VOOZH about

URL: https://www.geeksforgeeks.org/javascript/javascript-super-keyword/

⇱ JavaScript Super Keyword - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

JavaScript Super Keyword

Last Updated : 19 Jun, 2024

The super keyword is used to call the parent class's constructor to access its properties and methods.

Syntax:

super(arguments);
super.parentMethod(arguments);

Arguments:

This keyword can accepts all the arguments that has been used to create a constructor.

Example:  The code defines Person and FashionDesigner classes, where FashionDesigner extends Person. The person has methods for work, home, and sleep states. FashionDesigner adds a profession method and a combined task method. An instance of FashionDesigner is created, and its methods' outputs are displayed using a display function.


Output
Sayan is a Fashion Designer
Sayan is at home
Sayan is at work, Sayan is a Fashion Designer
Comment