Air
Air

Reputation: 81

Why do `Object` and `Function` have the same prototype?

Why Object.getPrototypeOf(Object) === Object.getPrototypeOf(Function) in JavaScript?

What is the purpose of this design?

Upvotes: 5

Views: 218

Answers (1)

SLaks
SLaks

Reputation: 887459

The __proto__ property of an object indicates the prototype that that object is inheriting.

Since Object and Function are both functions, they both have the same prototype, namely, Function.prototype.

Upvotes: 5

Related Questions