Prototypal Chaining
This lesson teaches the concept of prototype chaining in detail by using an example.
We'll cover the following...
We'll cover the following...
Look at the following code snippet, which uses the [[Prototype]] property of objects:
Let’s delve into the details of the code above.
When the prototype property of Rectangle is set to Shape, it is able to access all the properties present in Shape. So, upon accessing, if a property is not found in the object, such as if the name property is not found in Rectangle, JavaScript will automatically take it from the prototype of the object, Shape. This is known as prototypal inheritance.
As seen from the code above, since the prototype of ...