Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Prototypal inheritance was conceived to allow inheritance chains
that mimic the inheritance patterns found in traditional
object-oriented programming languages. Inheritance is
simply one object being given access to another object’s properties. This
is done by instantiating an instance of the object you want to inherit
from as the value for the prototype property of the
function that creates the object that is doing the inheriting. When this
is done, there is a link (a.k.a. __proto__) between the objects that
extends the available properties to an object upon property
lookup.
In the code below, Chef objects (i.e., cody) inherit from Person().This means that if a property is not
found in a Chef object, it will next be looked for on the prototype of the
function that created Person() objects.
To wire up the inheritance, all you have to do is instantiate an instance
of Person() as the value for Chef.prototype (i.e., Chef.prototype = new Person(); ).