JS Built-ins
Prototypesadvanced

Prototypes β€” Complex prototype chains

πŸ“– Usage Example
const obj = { x: 1 };
const child = Object.create(obj);
child.hasOwnProperty('x'); // false
'x' in child; // true

hasOwnProperty distinguishes own properties from inherited ones; 'in' checks the whole chain.

Understanding Multi-Level Inheritance

Prototype chains can be multiple levels deep. Properties and methods are inherited through the entire chain, with each level potentially adding or overriding properties.

Challenge: Build and navigate a multi-level prototype chain, understanding how properties are resolved and overridden at different levels.

πŸ’‘ Hints (3)
  • β€’ Property lookup continues up the chain until found
  • β€’ Own properties shadow inherited ones
  • β€’ this always refers to the object on which the method was called