The Object.create
method creates a new object that inherits from the object passed as an argument. If a property is missing in the new object, it will attempt to access the property from the prototype object. This delegation process allows you to share properties and methods among multiple objects.
As the example above, the child
object is created using the Object.create
method and inherits properties from the parent
object. When the child.heritage
property is missing, it is looked up in the parent
object and its value is inherited.
References