

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Super keyword in JavaScript?
Super
The super keyword is used to access and call functions on an object's parent. The super.prop and super[expr] expressions are legible in any method definition in both classes and object literals. It is used in the "extended" class, which uses "extends" keyword.
syntax
super(arguments);
Example
In the following example, the characteristics of a class called "Person" have been extended to another class called "Student". In both classes, we have used unique properties. Here "super" keyword is used to access a property from parent class(Person) to the extended class(Student), whereas "this" keyword is used to access extended class's own property.
<html> <body> <script> class Person { constructor(name, grade) { this.name = name; this.grade = grade; } goal() { return `${this.name} wants to become a crickter!`; } interest() { return `${this.name} interested in cricket !`; } } class Student extends Person { constructor(name, grade) { super(name, grade); } need() { return `${this.name} needs a cricket kit`; } career() { return `${super.interest()} ${super.goal()} ${this.need()}`; } } const student = new Student('Rishab pant', '7'); document.write(student.career()); </script> </body> </html>
Output
Rishab pant interested in cricket ! Rishab pant wants to become a crickter! Rishab pant needs a cricket kit
- Related Questions & Answers
- super keyword in Java
- Super keyword in Dart Programming
- Equivalent of Java Super Keyword in C#
- Role of super Keyword in Java Inheritance
- What are the uses of super keyword in java?
- Super Ugly Numbers JavaScript
- What are the three usages of the super keyword in Java?
- What is super() function in JavaScript?
- Class Keyword in JavaScript
- "extends" keyword in JavaScript?
- The yield* expression/keyword in JavaScript.
- Super Key in RDBMS
- Super Pow in C++
- Super Palindromes in C++
- Why can't we use the "super" keyword is in a static method in java?
Advertisements