JS Built-ins
Prototypesadvanced

Prototypes β€” Object.create patterns

πŸ“– Usage Example
const base = { hello() { return 'hi'; } };
const child = Object.create(base);
const grandchild = Object.create(child);
grandchild.hello(); // 'hi'

Prototype chains can extend multiple levels deep via repeated Object.create.

Advanced Object.create Usage

Object.create() enables several advanced patterns. You can create sealed object hierarchies, controlled property definitions, and sophisticated inheritance structures.

Challenge: Combine Object.create(), property descriptors, and prototype chains to build a flexible object system.

πŸ’‘ Hints (3)
  • β€’ Combine prototypes with descriptors for fine control
  • β€’ Use enumerable:false for private properties
  • β€’ writable:false creates immutable values