In the console, I executed two commands for understanding who was the prototype and got true twice. I want to understand what is the secret and who is the prototype of which (ancestor) in JS

Function.prototype.isPrototypeOf(Object) //true Object.prototype.isPrototypeOf(Function) //true 
  • How I Think Function Heir Object - ishidex2

1 answer 1

The fact is that Object and Function are two functions (so-called constructor functions). And any function in the prototype chain has both Function.prototype and Object.prototype , because any function is an object.

If you want to check who has a prototype, you need to work with prototypes and work:

 Function.prototype.isPrototypeOf(Object.prototype) // false Object.prototype.isPrototypeOf(Function.prototype) // true 

In general, the prototype chain looks like this (the prototypes below, the objects derived from them are at the top):

  Function Object \ / \ / | Function.prototype | | Object.prototype