Calling super class
by Krishna Ananthi
JavaScript
let Mammal = function(l) {
this.legs = l;
}
Mammal.prototype = {
walk() {
return 'walk'
},
sleep() {
return 'sleep'
}
}
let Bat = function(l, v) {
Mammal.call(this.legs);
this.isVeg = v;
}
console.dir(Bat)
Bat.prototype = Object.create(Mammal.prototype);
Bat.prototype.constructor = Bat;
Bat.prototype.fly=function(){
return 'fly';
}
console.dir(Bat);
let fruit= new Bat(4,true);
console.dir(fruit.sleep());
console.dir(fruit.fly());