Is there a rationale for why some of the convenience and reflection methods in JavaScript are defined on Object
, whereas others are defined on Object.prototype
? For instance, to find out whether an object a
is a prototype of object b
, you call isPrototypeOf
on a
:
a.isPrototypeOf(b)
Conversely, to get the prototype of object a
, you call getPrototypeOf
on Object
with a
as an argument:
Object.getPrototypeOf(a)
To me, this seems a little counterintuitive, at least at first sight -- I would expect that the characteristics of an object (like its prototype) can be queried starting from the object itself. (In other words, I would tend to expect a getPrototype
method on Object.prototype
, to be called as a.getPrototype()
, rather than a getPrototypeOf
method on Object
.)
This answer does a fairly good job explaining why you might want to pick one over the other, but the reasoning behind the particular decisions in the language standard (see getPrototypeOf
example above) is not entirely clear to me. But I guess there must be one :) What is it?