What is the prototype chain?
Every object in JavaScript has an internal link to another object, its prototype. When you read a property that the object does not have itself, the runtime looks at its prototype, and if that object does not have it either, it looks at that object's prototype, and so on until it reaches an object with no prototype at all.
That sequence is the prototype chain, and it is how inheritance works in the language. There is no copying of properties at all. An object that inherits from another does not contain a copy of the parent's properties; it contains a reference to the parent, and lookups walk down it.
const animal = {
speaks: true,
describe() { return "I am an animal"; },
};
const dog = Object.create(animal);
dog.name = "Rex";
console.log(dog.name); // "Rex" - own property
console.log(dog.speaks); // true - inherited
console.log(Object.getPrototypeOf(dog) === animal); // trueTwo properties of the chain are worth stating. It is a lookup, not a copy, so a change to the parent is visible through every child that inherits from it. And the chain is finite, ending at the object prototype, which itself has no prototype. That last object holds the methods every object has, such as toString and hasOwnProperty.
Because the chain is walked on every miss, an object with many missing properties is slower to read than one where the properties are present directly. That is one of the reasons the engine tracks shapes, so that the common case of many objects with the same layout is fast.