O'Reilly logo

Learn ECMAScript - Second Edition by Narayan Prusty, Mehul Mohan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Understanding the prototypal inheritance model

Each JavaScript object has an internal [[prototype]] property pointing to another object called its prototype. This prototype object has a prototype of its own, and so on, until an object is reached with null as its prototype. null has no prototype, and it acts as a final link in the prototype chain.

When trying to access a property of an object, and if the property is not found in the object, then the property is searched for in the object's prototype. If still not found, then it's searched for in the prototype of the prototype object. It keeps on going until null is encountered in the prototype chain. This is how inheritance works in JavaScript.

As a JavaScript object can have only one prototype, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required