JavaScript Prototype chain

Beginner
6 min read
Updated: Nov 2026

Definition and Usage

Every object has an internal link to another object called its prototype. When you read a property, JavaScript looks on the object, then on its prototype, and so on—the prototype chain—until it finds the property or reaches null.

JavaScript Syntax

JavaScript
const animal = { eats: true };
const dog = Object.create(animal);
dog.barks = true;
console.log(dog.barks);
console.log(dog.eats);
Try it Editor

How It Works

  1. Own property. barks is on dog.
  2. Inherited. eats is found on animal.

Examples

Example 1 — Classes use prototypes

Methods live on Class.prototype.

JavaScript
class A { hi(){ return 1; } }
console.log(new A().hi === A.prototype.hi);
Try it Editor

How It Works

  1. Same function shared on the prototype.

Example 2 — Object.create(null)

No prototype—pure dictionary.

JavaScript
const d = Object.create(null);
console.log(Object.getPrototypeOf(d));
Try it Editor

How It Works

  1. No inherited toString.

Example 3 — getPrototypeOf

Inspect the link.

JavaScript
console.log(Object.getPrototypeOf([]) === Array.prototype);
Try it Editor

How It Works

  1. Arrays inherit Array methods.

Frequently Asked Questions

Prefer Object.getPrototypeOf / Object.create. __proto__ is legacy.
extends wires the prototype chain for you.

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

6 people found this page helpful