Javascript Prototypal Inheritance

added by JavaScript Kicks
9/2/2014 1:51:13 PM


Everything in JavaScript is an object. There are no classes. So when we talk about inheritance, we are talking about objects directly inheriting from other objects. To achieve inheritance, broadly speaking, we need to store the reference of the parent in the child somewhere. When a property look-up happens in the child, the child is searched first, and if the property is not found there, we move to its parent and search. And so on, until we hit the end of the inheritance chain.