Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

187
Views
What does getPrototypeOf of a Class point to?
Object.getPrototypeOf(..)

returns the prototype (i.e. the value of the internal [[Prototype]] property) of the specified object. so, the below makes sense

const prototype1 = {};
const object1 = Object.create(prototype1);

console.log(Object.getPrototypeOf(object1) === prototype1); // logs true

Even this looks fine

function fn() {
}
Object.getPrototypeOf(fn) == Function.prototype // logs true

But I am kind of confused why

Object.getPrototypeOf(Object) == Function.prototype // logs true

Please explain

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Some points to consider:

Object is a function

It can be used to convert a primitive to an object. Like Object("test") will create a String instance.

There is a constructor for functions

The constructor for functions is Function. It is not commonly done, but you can create a function by calling this constructor. For example: new Function("alert('test')") returns a function that when called will display an alert.

Functions which are created with function statements, expressions, arrow function syntax,... also have as constructor this Function. So for instance, eval.constructor === Function is a true expression. The same goes for Object.constructor === Function. You can do this for any function.

Where to find the a function's prototype object?

Like every constructor, Function has a prototype property. That object defines the prototype properties and methods that all functions inherit. We can find that prototype object via Function.prototype, or we can find it by taking a Function instance (i.e. a function), and getting its prototype object. This we do by calling Object.getPrototypeOf on a specific function.

Equalities

And so we can see that all of the following are equal:

var a = Object.getPrototypeOf(eval);
var b = Object.getPrototypeOf(parseInt);
var c = Object.getPrototypeOf(function () {});
var d = Object.getPrototypeOf(RegExp);
var e = Object.getPrototypeOf(Object);
var f = Function.prototype;

// All true:
console.log(a === f, b === f, c === f, d === f, e === f);

about 4 years ago · Juan Pablo Isaza Report

0

Everything in JavaScript inherits from Object.prototype. That is why everything in JavaScript is said to be objects. Even functions and arrays are objects under the hood.

So Object.prototype is the prototype of:

  • Function.Prototype
  • Array.Prototype

Function.Prototype is the prototype of Function and Array:

Array.prototype.prototype == Function.Prototype // true
Function.prototype.prototype == Function.Prototype // true

And again, Array and Function inherits from Object.prototype:

Object.getPrototypeOf(Array.prototype) == Object.prototype // true
Object.getPrototypeOf(Function.prototype) == Object.prototype // true

So to return to your question. The prototype of Object is Object.prototype. And Object.prototype is the prototype of Function.prototype, thus:

Object.getPrototypeOf(Object) == Function.prototype // true

JavaScript is like a family tree: Object.prototype had a baby called Function.prototype. Function.prototype then had babies of its own called Array and Function. And then follows arrays, classes etc... In the end, everything leads back to Object

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!