Skip to main content

Prototypes and the Prototype Chain

Learn Prototypes and the Prototype Chain (Phase 10 · Classes, Prototypes, OOP (Important), JavaScript) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.

Objects inherit from objects • Every object has a hidden link to another object, its prototype . When a property is not found on the object, JavaScript looks it up the prototype chain until it reaches null . • Read the link with Object.getPrototypeOf(obj) . Create an object with a chosen prototype using Object.create(proto) . • Methods placed on a shared prototype exist once in memory, instead of being copied into every object.

More lessons in Phase 10 · Classes, Prototypes, OOP (Important)