Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
While it’s only an object, prototype is special because the prototype chain
links every instance to its constructor function’s
prototype property. This means that any time an object
is created from a constructor function using the new keyword (or when an object wrapper is
created for a primitive value), it adds a hidden link between the object
instance created and the prototype property of the
constructor function used to create it. This link is known inside the
instance as __proto__ [though it
is only exposed/supported via code in Firefox 2+,
Safari, Chrome, and Android]. JavaScript wires this together in the
background when a constructor function is invoked and it’s this link that
allows the prototype chain to be, well, a chain. Below, we add a property
to the native Array() constructor’s
prototype, which we can then access
from an Array()
instance using the __proto__ property set on that
instance.