Created
May 22, 2018 17:04
-
-
Save sagardere/6caa80239cdb38c4a703b1b23da74ccc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Animal{ | |
constructor(name , height){ | |
this.name = name; | |
this.height = height; | |
} | |
Hello(){ | |
console.log("Hello from Animal"); | |
} | |
} | |
//Extends class Parents/Animal | |
class Lion extends Animal{ | |
constructor(name , height , color){ | |
super(name , height);//call to super class | |
this.color = color;//add new parameter | |
} | |
Hello(){ | |
super.Hello(); | |
console.log("Hello fron Lion"); | |
} | |
} | |
//Here Creating Instances Parent Class/Animal | |
//when create class instance by default call to constructor. | |
let king_1 = new Animal(); | |
let king_2 = new Animal('Tiger' , 3.2); | |
//Creating instance of child class/Lion | |
let son = new Lion('Dog' , 3.2 ,'red'); | |
son.Hello(); //Hello from Lion |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment