Last active
July 4, 2020 15:43
-
-
Save julienetie/3d152d50a6308b5ccf2111f4822cbfad to your computer and use it in GitHub Desktop.
This file contains 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
/* Object Oriented JavaScript */ | |
class Animal { | |
constructor(name) { | |
this.name = name; | |
} | |
speak() { | |
console.log(`${this.name} makes a noise.`); | |
} | |
} | |
class Dog extends Animal { | |
constructor(name) { | |
super(name); // call the super class constructor and pass in the name parameter | |
} | |
speak() { | |
console.log(`${this.name} barks.`); | |
} | |
} | |
/* | |
let d = new Dog('Mitzie'); | |
d.speak(); // Mitzie barks. | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment