Here's how prototype inheritance works.
When you use Object.create
to create a new object from an existing object, properties are inherited from the object from which the object is created. Thus, a newly created object may look empty, but it contains a reference to inherited properties from the parent.
__proto__
, .
, , , Object
. Object
, /.
_____________ _____________ ______________
|Own Members| -----> | foo | -->| toString() |
| | | | bar | | | valueOf() |
| | | | | | | |
|___________| | |____________| | | |
| __proto__ |-------| | __proto__ |-----...-- | |
------------- -------------- --------------
inherited_obj some_obj Object
, , Object
, .
, , __proto__
.