I was wondering if there is any difference between using Object.create() and simply reassigning?
Using Object.create()
function Rectangle(length, width) {
this.length = length;
this.width = width;
}
function Square(size) {
this.length = size;
this.width = size;
}
Square.prototype = Object.create(Rectangle.prototype, {
constructor: {
configurable: true,
enumerable: true,
value: square,
writable: true
}
});
Reassigning
function Rectangle(length, width) {
this.length = length;
this.width = width;
}
function Square(size) {
this.length = size;
this.width = size;
}
Square.prototype = Rectangle.prototype;
Square.prototype.constructor = Square;