function inheritance
by Saksham Malhotra
JavaScript
function bird(color, life) {
this.color = color;
this.life = life;
this.tellColor = function() {
console.log(`the color is ${this.color}`);
}
}
function parrot(color, life, song) {
bird.call(this, color, life);
this.song = song;
this.sing = function() {
console.log(`bird is singing ${this.song}`);
}
}
let sparrow = new bird('brown', 2);
sparrow.tellColor();
//sparrow.sing(); error
let aParrot = new parrot('green', 40, 'summer of 69');
aParrot.tellColor();
aParrot.sing();