I am reading a tutorial, and I don't understand the logic behind this:
function inheritPrototype(childObject, parentObject) {
var copyOfParent = Object.create(parentObject.prototype);
copyOfParent.constructor = childObject;
childObject.prototype = copyOfParent;
}
So I understand that there needs to be an intermediary because if you did child.prototype = parent.prototype;
any changes to the child would be done to the parent. But that's done in Object.create(parentObject.prototype);
So why does there need to be another intermediary?
Aucun commentaire:
Enregistrer un commentaire