class inheritance
JavaScript
class bird {
constructor(color) {
this.color = color;
}
tellColor() {
console.log(`the color is ${this.color}`);
}
}
class parrot extends bird {
constructor(color, song) {
super(color);
this.song = song;
}
sing() {
console.log(`parrot is singing ${this.song}`);
}
}
let sparrow = new bird('brown');
sparrow.tellColor();
let aParrot = new parrot('green', 'summer of 69');
aParrot.tellColor();
aParrot.sing();