I've seen this question and I know how to extend a class. However, is it good practice to do that with a method? Is it safe to use this:
function extendClass(child, parent) {
child.prototype = Object.create(parent.prototype);
child.constructor = child;
}
extendClass(Banana, Fruit);
instead of this:
Banana.prototype = Object.create(Fruit.prototype);
Banana.prototype.constructor = Banana;