JavaScript doesn't have classical inheritance — it has prototypal inheritance. Understanding the prototype chain is essential for interviews and debugging.
The Prototype Chain
Every object has an internal [[Prototype]] link. When you access a property, JS walks up the chain until it finds it or reaches null.
Constructor Functions
ES6 Classes (Syntactic Sugar)
Common Gotchas
Object.create(null)creates an object with NO prototype — no toString, no hasOwnProperty. Used for pure dictionaries.hasOwnPropertyvsin:inchecks the chain,hasOwnPropertychecks only the object- Modifying
Array.prototypeorObject.prototypeaffects ALL instances — never do this in production __proto__is deprecated — useObject.getPrototypeOf()andObject.setPrototypeOf()
Performance
V8 optimizes prototype lookups with hidden classes and inline caches. Long prototype chains (5+) can degrade performance. Keep inheritance shallow.