My understanding on the concept: objects come with a hidden property called
__proto__ that provides reference to function object's prototype property. When I create an empty object and log it into the console, I see the property within the object is
[[Prototype]] instead of
__proto__. Can you provide any insight or correction to my understanding on the concept?
The value contained in an internal slot can often be retrieved if there are methods that deliberately expose it.
For another example of an internal slot, consider the values of a Set:
const set = new Set(); set.add('someValue');
someValue is not directly visible on the Set, but it can be accessed through methods which run native code, and that native code accesses the internal slots of the Set to see what it contains - for example, with
In the case of
[[Prototype]], the value in that internal slot can be retrieved by invoking the
__proto__ getter, which does:
- Return ?
eventually accessing and returning the
[[Prototype]] internal slot.
__proto__ is deprecated - you should prefer to use