Object Prototype and Prototypal Inheritance
Prototype lookup checks an object’s own properties and then follows its prototype chain until it finds the property or reaches null.
Sharing behavior through a prototype does not copy that behavior into every object.
See the mechanism
article owns title↓no own categoryFollow one example
The first category read falls back to defaults. It is not an own property of article. Assigning article.category creates an own property for this ordinary writable case and shadows the inherited value; defaults.category remains General. Avoid confusing an object’s internal prototype link with an ordinary property named prototype on constructor functions.
Predict, change and check
Predict: After creating article.category, will deleting that own property reveal the inherited category again?
Test your explanation: Delete article.category and read it. Compare the result with deleting defaults.category instead.
The tasks below ask you to explain that result and apply the idea to different inputs.
Apply and distinguish
Lookup, shadowing and construction are related but different
Reading a missing own property can follow the object's internal prototype chain until it finds a property or reaches null. Adding an own property can shadow an inherited one; deleting that own property can reveal the inherited value again. The behavior depends on descriptors and accessors as well as the simple writable example.
An object's prototype link is not the same thing as an ordinary constructor function's prototype property. Object.create chooses a prototype for a new object, while new uses constructor behavior and its prototype relationship. Inspect ownership with Object.hasOwn and inspect the actual link with Object.getPrototypeOf instead of using ambiguous labels.
Check your understanding: State the input contract, identify the operation that changes the result, and give one boundary input that would distinguish the correct rule from the mistake described above.