I need some help for understanding the prototype chain. I don't understand / not quite sure if my assumptions are correct. I want to understand the link to the Object.prototype. One example
function A(){};
var newObject=new A();
I know the newObject has an internal property [[prototype]] which has a reference to A.prototype. And this prototype-Object has also an internal property with reference to Object.prototype, right? But why does it have that reference? Is it because the prototype of A (used as constructor) is an object which can be imagined to be created by A.prototype=new Object() ( which will be done automatically in the background). And now I have a reference to the prototype of Object? I hope I explained it clearly. Please let me know your comments.
Many thanks
Objectin it, that's why you can do({ a: 3 }).toString()for exampleObject.create(null).toString()won't work. (Just nitpicking.)null.toString()would work. They madetypeof null === 'object'in JavaScript, but didn't really make it an object.typeof nullbeing'object'is actually because of a kind-of bug in the first version of JS, and they standardized it because people relied on it by then. End of tangent.) I just wanted to say that not every object hasObject.prototypein its prototype chain, even though most of them does.