JavaScript is a prototypical language where inheritance is achieved via prototypes. This can be a daunting concept, but it is, in fact, beautifully simple. JavaScript's prototypal behavior can be described like this: every time a property is accessed on an object, if it is not available on the object itself, JavaScript will attempt to access it on an internally available property called [[Prototype]]. It will then repeat this process until it either finds the property or gets to the top of the prototype chain and returns undefined.
The prototype
Understanding what this [[Prototype]] property is capable of will give you great power over the language and will immediately make JavaScript less daunting. It can be difficult to grasp but is worth ...
Get Clean Code in JavaScript now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.