Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Since the prototype property is an object, the
last stop in the prototype chain or lookup is at Object.prototype. In the code below, I create
myArray, which is an empty array. I
then attempt to access a property of myArray which has not yet been defined, engaging
the prototype lookup chain. The myArray
object is examined for the foo
property. Being absent, it then looks for the property at Array.prototype, but it is not there, either. So
the final place it looks is Object.prototype. Because it is not defined in
any of those three objects, the property is undefined.
<!DOCTYPE html><html lang="en"><body><script> var myArray = []; console.log(myArray.foo) // logs undefined /* foo was not found at myArray.foo or Array.prototype.foo or Object.prototype.foo, so it is undefined. */ </script></body></html>