I don't understand something>Let's take a look at MDN's example:
function Product(name, price) {
this.name = name;
this.price = price;
if (price < 0) {
throw RangeError('Cannot create product ' +
this.name + ' with a negative price');
}
return this;
}
function Food(name, price) {
Product.call(this, name, price);
this.category = 'food';
}
Food.prototype = Object.create(Product.prototype);
Food.prototype.constructor = Food; // Reset the constructor from Product to Food
Why I must write this part:
Food.prototype = Object.create(Product.prototype);
Food.prototype.constructor = Food;
Isn't the Product.call(this, name, price);
already copied that property(Prototype) from Product to Food?