我想知道使用Object.create()和简单重新分配之间是否有任何区别?
使用Object.create()
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;
重新分配
{{1}}