JavaScript8 min read
JavaScript Prototypes and Inheritance
Understand JavaScript prototypes. Learn how inheritance works under the hood with prototype chain.
Alex Thompson
Dec 19, 2025
21.4k835
JavaScript Prototypes
What are Prototypes?
Every object has a prototype. It's like a parent object that provides properties and methods.
┌─────────────────────┐
│ Object │
│ ┌───────────────┐ │
│ │ name: "John" │ │
│ └───────────────┘ │
│ │ │
│ │ __proto__ │
│ │ │
┌─────────▼───────────┐
│ Prototype │
│ ┌───────────────┐ │
│ │ toString() │ │
│ │ valueOf() │ │
│ └───────────────┘ │
└─────────────────────┘
Prototype Chain
const arr = [1, 2, 3];
arr.push(4); // Method from Array prototype
arr.toString(); // Method from Object prototype
JavaScript looks up the chain:
Array → Array.prototype → Object.prototype → null
Key Takeaway
Prototypes enable inheritance. Objects inherit from prototypes. Prototype chain allows method lookup. Understanding prototypes is key to advanced JavaScript.
#JavaScript#Prototypes#Inheritance#Advanced