Code is from mozilla website
function Product(name, price) {
this.name = name;
this.price = price;
if (price < 0)
throw RangeError('Cannot create product "' + name + '" with a negative price');
return this;
}
function Food(name, price) {
Product.call(this, name, price);/// why not this be Product(name,price)
this.category = 'food';
}
Food.prototype = new Product();
may very silly thing, can't understand this line
Product.call(this, name, price);
Since both Product and Food are global functions why do we have to use Product.call