I have the following code which I am confused why when I define a prototype of property 'name' it comes out as '40' and not 'fred'? what is going on inside javascript? this seems like a simple question but one that I am confused about. Thanks!
function Product(id){
this.id = id
this.name = id + 20
}
Product.prototype.name = 'fred';
var p = new Product(20);
console.log(p.name);
40inside the constructor - shadowing the value that would be inherited from the prototype.