Prototype Chain: Inheritance Without Classes

Read a key, watch JS walk the [[Prototype]] hop by hop with Object.hasOwn until it is found or null. Shadowing, for...in, a circular chain. An interactive…

Why it matters

Almost all inheritance in JavaScript, class included, runs through this chain: array methods, DOM methods, the toString on every object. Knowing how the walk goes explains why methods seem to come from nowhere, why for...in brings inherited keys along, why a mistyped property name becomes undefined, and why changing a built-in prototype is dangerous.

The key idea

Reading a property is a walk, not a copy

Common mistakes

Try it in this playground