What is a prototype chain?
✅ Simple Explanation of Prototype Chain in JavaScript:
In JavaScript, every object has a hidden property called [[Prototype]] (accessible using __proto__), which points to another object. This forms a chain — called the prototype chain.
💡 Think of it like this:
Imagine you're looking for a book in your room:
-
First, you check your own shelf (the object itself).
-
If not found, you ask your parents (the object's prototype).
-
If they don’t have it, they ask your grandparents, and so on...
👉 This is how JavaScript looks for properties or methods — it goes up the prototype chain until it finds it or reaches the top (null).
Comments
Post a Comment