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:

  1. First, you check your own shelf (the object itself).

  2. If not found, you ask your parents (the object's prototype).

  3. 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

Popular posts from this blog

What is Class in js