I encountered some confusion when learning the prototype chain as follows:
in some blogs (such as Ruan Yifeng"s blog), it is said:
.JavaScript
natively providesObject
objects, and all other objects inherit fromObject
objects, that is, those objects are instances ofObject
I"m confused here. As far as I understand, shouldn"t Object
be a constructor? Because, for example, any instance object has a .valueof
method, which is actually a referenced
method in the prototype object Object.prototype
, and when I type typeof (Object)
in the terminal, it returns "function"
, indicating that Object
should be a constructor, and the real object should be Object.prototype
bar
but it doesn"t seem to be quite the case. Object
has its own static method, which is defined directly in its own method, such as Object.keys ()
, so the constructor is also an object? Can you also have your own methods and properties?
another test was done:
var F = function() {}
F.__proto__ === Function.prototype // true
how to understand this question? I just learned javascript
. After learning these concepts, I began to be a little confused. I hope you seniors can give a clear answer. Thank you