My question is Object is last on prototype chain all objects inherit properties and methods from it how it is inherit methods from Function.prototype, why Object.__proto__ === Function.prototype
// true, why Object.__proto__
is not null.
Asked
Active
Viewed 51 times
1

javascript lover
- 116
- 7
-
No normal object inherits from `Object` in javascript. They all inherit from `Object.prototype` (which is also the `Object.getPrototypeOf(Function.prototype)`). You will find that `Obect.getPrototypeOf(Object.prototype) === null` as expected. – Bergi Sep 09 '20 at 20:40
2 Answers
0
The fundamental Object
in JavaScript has to have a way for it to be instantiated, so it requires a prototype
object to aid in lines like this:
let myObj = new Object();
And that is why Object.__proto__
is not null
.
The Function
object is a special type of object that facilitates object instantiation via a constructor and when used this way is known as a "constructor function". So, it makes sense for Object
to inherit from a Function
object so that object instances can be made.

Scott Marcus
- 64,069
- 6
- 49
- 71
-
its mean that Function and Object inherit methods and properties from each other ? – javascript lover Sep 09 '20 at 20:35
-
-
@javascriptlover `Function` is the last of the prototype chain. As you correctly point out `Object._proto__ === Function()` – Scott Marcus Sep 09 '20 at 20:46
-
-
I think you are confusing `__proto__` and `prototype`. `__proto__` is the actual object that is used in the lookup chain to resolve methods, etc. `prototype` is the object that is used to build `__proto__` when you create an object with new – Scott Marcus Sep 09 '20 at 20:52
-
@ScottMarcus What do you mean by "*The Function object is a special type of object that facilitates object instantiation via a constructor*"? – Bergi Sep 09 '20 at 21:05
-
I don't know if this helps or not, but `Object.getPrototypeOf(Object.getPrototypeOf(Object))` is `null`. `Object.getPrototypeOf(Object)` is a function, but not `Function`. – evolutionxbox Sep 09 '20 at 21:26
-
Why Function.__proto__.__proto__ === Object.prototype // true – javascript lover Sep 09 '20 at 21:30
0
Function is also an object. So it inherits from Object too.
But don't be confused by Object.__proto__
. That's something the browser adds and isn't actually part of the language. So don't rely on it or use it.
Essentially, Function.prototype
is Object.__proto__
.

Geuis
- 41,122
- 56
- 157
- 219
-
-
1
-
No, `Object` inherits from `Function`, which is implemented as native code. This is how/why objects have the ability to be called with the `new` keyword as constructor functions. Open your browser console and type: `Function.prototype;` and see what you get. – Scott Marcus Sep 09 '20 at 20:47
-
@ScottMarcus What Geuis meant is that Function is a subclass of Object, and all functions are objects. No, `Object` does not inherit from `Function`. At best, it does inherit from `Function.prototype`, and it's an `instanceof Function`. – Bergi Sep 09 '20 at 21:03
-
@ScottMarcus riiight. Bit rusty, I've been off work for a few months. Sorry. Yeah, Object does inherit from Function, which is why you can do `new Function()` and `new Object()`. But @Bergi is clarifying what I was trying to say originally. – Geuis Sep 09 '20 at 21:04