Skip to content

Instantly share code, notes, and snippets.

@agoiabel
Created April 14, 2018 08:02
Show Gist options
  • Select an option

  • Save agoiabel/0a09fe1c2c04a34ed231feb9c32d92bd to your computer and use it in GitHub Desktop.

Select an option

Save agoiabel/0a09fe1c2c04a34ed231feb9c32d92bd to your computer and use it in GitHub Desktop.
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