var P = {
name: "James"
};
var j = Object.create(P);
console.log(j.name);
j.name = "James";
console.log(j.name);
P.prototype.test = "love";
console.log(P.test);
I have the code above. It gives me an error that I cannot set that I cannot set property 'test' of undefined. I thought every object has a prototype? Doesn't the P object have a prototype? and shouldn't any method declared on that prototype be available to j?
Also can someone explain to me what the Object.create() function does?