When creating the following function from the window object like this,
function userInfo() {};
how come the userInfo.constructor displays Function instead of Object since functions are objects?
It even display Function instead of Object when using the following,
Function.constructor
userInfo.constructor
is Function
because:
userInfo
has no own constructor
property.userInfo
's [[Prototype]] internal slot is Function.prototype
.Function.prototype
has an own constructor
property, whose value is Function
.Function.constructor
is Function
too because of the same reason:
Function
has no own constructor
property.Function
's [[Prototype]] internal slot is Function.prototype
.Function.prototype
has an own constructor
property, whose value is Function
.That is, Function
instances (like userInfo
or Function
itself) inherit a constructor
property from Function.prototype
, which can be used to know they are instances of Function
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With