Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

JS Puzzles · Const

Prototype chain

JavaScript resolves a missing property by searching the object's prototype, then that prototype's prototype, until it finds a match or reaches null. This linked lookup structure is the prototype chain.

How it works

An object can delegate missing property lookups to its prototype, whose own prototype is checked next. This continues until a matching property is found or the chain reaches null; Object.getPrototypeOf and Object.setPrototypeOf inspect and change that internal link.

Syntax

Object.getPrototypeOf(obj)
Object.create(proto)

Parameters

NameTypeDescription
objobjectThe object whose prototype is inspected.
protoobject or nullThe prototype object to use for the new object.

Returns

Object.getPrototypeOf() returns an object's prototype; Object.create() returns a new object using the supplied prototype.

Key points

  • Objects participate in inheritance through a prototype link.
  • Because prototypes are objects too, they can form a chain.
  • The terminal prototype is identified by having null as its prototype.
  • Property access first checks the receiver, then delegates to its prototype.
  • Use Object.getPrototypeOf to inspect an object's prototype without relying on the legacy accessor.
  • Object.create constructs an object with a chosen prototype.

Common mistakes

  • An object's prototype link is distinct from its constructor's prototype property; do not confuse the two.
  • A missing property may be searched through multiple prototypes before the lookup ends.
  • If no prototype supplies the property, the lookup evaluates to undefined.

Example: Property lookup through a prototype chain

const parent = { shared: true };
const child = Object.create(parent);
child.own = 1;

console.log(child.own); // 1
console.log(child.shared); // true
console.log(Object.getPrototypeOf(child) === parent); // true
console.log(child.missing); // undefined

The child keeps its own property and finds shared through its prototype; an absent property remains undefined.

When to use it

Delegated behavior

Share methods or default values across related objects without copying them into every object.

Trace inheritance

Inspect how an object inherits properties during debugging or puzzle solving.

Control object inheritance

Create an object with a deliberate prototype, including a null-prototype dictionary.

  • Object.getPrototypeOf()
  • Object.create()
  • Object.prototype
  • __proto__
  • prototype chain

Source: Object prototypes. Checked 2026-10-15.