Created
April 14, 2018 08:02
-
-
Save agoiabel/0a09fe1c2c04a34ed231feb9c32d92bd 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 Human { | |
| constructor () { | |
| this.gender = 'Male'; | |
| } | |
| printGender() { | |
| console.dir(this.gender); | |
| } | |
| } | |
| //The extends keyword means | |
| //we are inheriting from the Human | |
| class Person extends Human { | |
| constructor () { | |
| //we have to call the super constructor | |
| super(); | |
| this.name = 'Abel'; | |
| } | |
| printMyName() { | |
| console.dir(this.name); | |
| } | |
| } | |
| //We can call the class like below:: | |
| const person = new Person(); | |
| person.printMyName(); //we return 'Abel'; | |
| person.printGender(); //we console 'Male'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment