Let me introduce the term description. This is the text from the “Description“ cell of the internal method [[setPrototypeOf]] in the specification table Table 4: Essential internal methods.
Also, below I use the term target from the specification clause.
The target of an internal method is the object upon which the internal method is called.
I only recently started reading the specification. I think I'm confused by the description.
var obj_proto = {};
var obj = {};
Object.setPrototypeOf(obj_proto, null);
Object.setPrototypeOf(obj, obj_proto);
I've included this code solely to illustrate the operation of the internal method [[setPrototypeOf]] algorithm works, because it is used in the algorithm of the internal method [[setPrototypeOf]] of the built-in Object constructor, and the built-in Object constructor is present in the implementation (or host, I'm not sure). This question isn't about the implementation (or host).
-
The
obj_protoobject is the prototype for theobjobject.obj_protohas no prototype. If I understand correctly, theobj_protoprototype does not provide any shared properties for theobjobject. -
According to the description, if I pass an object as the
[[setPrototypeOf]]argument, it means that the object provides inherited properties to the target. If I pass null, it means that the target has no inherited properties. -
No one provides inherited properties for
obj. This means, according to the description, I passed null to[[setPrototypeOf]].
I see a contradiction between what is written in the description and how the algorithm of the internal method [[setPrototypeOf]] is written.
I have no issues with the algorithm. It's wonderful. But if my reasoning is correct, I think it would be better to change the first sentence of the description from “Associate this object with another object that provides inherited properties.“ to “Associate this object with another object.“.
PS (23.03):
I was wondering. From a specification standpoint, a prototype is an object that provides shared properties for other objects.
If obj_proto doesn't provide any shared properties for obj, is it a prototype for obj?