JSFiddle - React, Tailwind, and code Playground
by Artem
JavaScript
'use strict';
function Animal(numOfLegs) {
this.numOfLegs = numOfLegs;
}
Animal.prototype.eatFood = function(food) {
console.log(`Num num num ${food}`);
};
function Dog() {
Animal.call(this, 4);
}
Dog.prototype.eatFood = function(food) {
Object.getPrototypeOf(Dog.prototype).eatFood.call(this, food);
};
function __extends(targetClass, sourceClass) {
targetClass.prototype = Object.create(
sourceClass.prototype,
{ ...Object.getOwnPropertyDescriptors(targetClass.prototype),
constructor: {
value: targetClass
}
}
);
}
__extends(Dog, Animal);
new Dog().eatFood('meat');