¿Cuáles son las diferencias entre Rectangle.prototype = Object.create (Shape.prototype) y Rectangle.prototype = Shape.prototype?
Estaba leyendo los siguientes códigos y comencé a preguntarme ¿Cuáles son las diferencias entreRectangle.prototype = Object.create(Shape.prototype)
yRectangle.prototype = Shape.prototype
? ya que tanto Object.create (Shape.prototype) como Shape.prototype devuelve un Object.
//Shape - superclass
function Shape() {
this.x = 0;
this.y = 0;
}
Shape.prototype.move = function(x, y) {
this.x += x;
this.y += y;
console.info("Shape moved.");
};
// Rectangle - subclass
function Rectangle() {
Shape.call(this); //call super constructor.
}
Rectangle.prototype = Object.create(Shape.prototype);