0

What's the type of prototypes in Javascript?

I mean for example the type of:

  • Object.prototype
  • Boolean.prototype
  • Number.prototype
  • String.prototype
  • Date.prototype
  • RegExp.prototype
  • Array.prototype
  • Set.prototype
  • Map.prototype
  • Function.prototype

When using typeof all of them return "object", but I was wondering if they are instances of a particular type of Object.

Aliuk
  • 1,249
  • 2
  • 17
  • 32
  • Umm, yes. `Boolean.prototype` is a type of object that is a boolean prototype. `Number.prototype` is similarly a type of object that is a number prototype. And so on. They are all instances of a particular type of object, each of them being themselves. – VLAZ Jul 09 '21 at 22:05
  • How about this one? https://stackoverflow.com/questions/21299416/what-type-of-object-is-a-javascript-prototype – admcfajn Jul 09 '21 at 22:10
  • What exactly do you mean by "particular type of object"? `Array.prototype` actually is an array (exotic object), and `Function.prototype` is actually callable, but besides that, objects in JavaScript are just defined by their prototype chain - try to follow that for the objects you listed. – Bergi Jul 09 '21 at 23:22
  • What I mean by "particular type of object" is some object that retrieves "true" when used with "instanceof". – Aliuk Jul 09 '21 at 23:52
  • They are all instances of `Object`. But other than that, there isn't a `Prototype` object that is on the prototype chain of any prototype. – VLAZ Jul 10 '21 at 06:39

0 Answers0