How to implement inheritance in ES6 ? Last Updated : 08 Nov, 2021 Comments Improve Suggest changes 3 Likes Like Report In this article, we will know how inheritance is implemented in es6. The ES6 JavaScript supports Object-Oriented programming components such as Object, Class and Methods. Further in Classes we can implement inheritance to make child inherits all methods of Parent Class. This can be done using the extends and super keywords. We use the extends keyword to implement the inheritance in ES6. The class to be extended is called a base class or parent class. The class that extends the base class or parent class is called the derived class or child class. The super() method in the constructor is used to access all parent's properties and methods that are used by the derived class. The below example will demonstrate the use of the extends and super keywords. Example: Let us create a Shop class that will inherit the methods from the parent "Mall" class. HTML <!DOCTYPE html> <html> <body> <h2>JavaScript Class Inheritance</h2> <p id="demo"></p> <script> class Mall { constructor(shopname) { this.shopname = shopname; } shopispresent() { return this.shopname + ' is present in the '; } } class Shop extends Mall { constructor(name, mallname) { super(name); this.mallname = mallname; } showshop() { return this.shopispresent() + this.mallname; } } let newMall = new Shop( "Domino", "Select City Walk Mall" ); document.getElementById("demo") .innerHTML = newMall.showshop(); </script> </body> </html> Output: Explanation: In the above example, the super keyword is used as a “function” which calls the parent class Mall with the parameter passed to Shop. This is a key step to be carried out in order to make sure that Shop is an instance of Mall.On the other hand, extends keyword is used to set Shop as a subclass or child class of Mall. The use of extends is a must to set some class as a child of other class. Create Quiz Comment F faizamu19 Follow 3 Improve F faizamu19 Follow 3 Improve Article Tags : JavaScript Web Technologies ES6 JavaScript-Questions Explore JavaScript BasicsIntroduction to JavaScript4 min readVariables and Datatypes in JavaScript6 min readJavaScript Operators5 min readControl Statements in JavaScript4 min readArray & StringJavaScript Arrays7 min readJavaScript Array Methods7 min readJavaScript Strings5 min readJavaScript String Methods9 min readFunction & ObjectFunctions in JavaScript5 min readJavaScript Function Expression3 min readFunction Overloading in JavaScript4 min readObjects in JavaScript4 min readJavaScript Object Constructors4 min readOOPObject Oriented Programming in JavaScript3 min readClasses and Objects in JavaScript4 min readWhat Are Access Modifiers In JavaScript ?5 min readJavaScript Constructor Method7 min readAsynchronous JavaScriptAsynchronous JavaScript2 min readJavaScript Callbacks4 min readJavaScript Promise4 min readEvent Loop in JavaScript4 min readAsync and Await in JavaScript2 min readException HandlingJavascript Error and Exceptional Handling6 min readJavaScript Errors Throw and Try to Catch2 min readHow to create custom errors in JavaScript ?2 min readJavaScript TypeError - Invalid Array.prototype.sort argument1 min readDOMHTML DOM (Document Object Model)8 min readHow to select DOM Elements in JavaScript ?3 min readJavaScript Custom Events4 min readJavaScript addEventListener() with Examples9 min readAdvanced TopicsClosure in JavaScript4 min readJavaScript Hoisting6 min readScope of Variables in JavaScript3 min readJavaScript Higher Order Functions7 min readDebugging in JavaScript4 min read Like