Each object in Javascript will have a prototype. Try it:
The code copy is as follows:
var Richard = new Object();
alert(typeof(Richard.prototype));
The result is depressing, and what pops up with the browser is undefined...
What's going on?
Let’s take a look at another example:
The code copy is as follows:
function Richard(){}
alert(typeof(Richard.prototype));
The above example seems to show that only function objects have prototypes, while general Object objects do not have prototypes. What is the truth?
Let’s implement another sentence and understand:
The code copy is as follows:
var Richard = new Object();
alert(Richard.__proto__);
Do you understand?
In fact, we all have a misunderstanding, which is that the prototype chain of Javascript objects is a property named prototype and can be accessed. In fact, Javascript's prototype and the attribute named prototype have no relationship at all at the beginning, and are two different things.
For general objects, we can only access the prototype inherited from the Object object through attributes such as __proto__;
For a function object, when it is established, the prototype of the Function object has been assigned to the prototype property.