"extends" keyword in JavaScript?

JavascriptFront End TechnologyObject Oriented Programming


'extends' keyword is used to create a class inheritance. A class created with a class inheritance will inherit all the methods from another class. Let's discuss it in a nutshell.


In the following example, 'extends' keyword is used to inherit the properties from the class 'Company' to the class "model".The super() method refers to the parent class. Calling the super() method in the constructor method is nothing but calling the parent's constructor method and gets access to the parent's properties and methods.

Live Demo

<p id="method"></p>
   class Company {
      constructor(branch) {
      this.name = branch;
      method() {
         return this.name + " has a product that is ";
   class Model extends Company {
      constructor(branch, pname) {
         this.model = pname;
      result() {
         return this.method() + " " + this.model;
   mycar = new Model("Tutorialspoint", "Tutorix");
   document.getElementById("method").innerHTML = mycar.result();


Tutorialspoint has a product that is Tutorix
Updated on 02-Aug-2019 15:20:08